Skip to content

Conversation

@milankl
Copy link
Contributor

@milankl milankl commented Jan 25, 2021

No description provided.

test/runtests.jl Outdated
end
end

include("randfloat.jl")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you move this line of include to line 3 to be consistent?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, but that's not the error message, right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No it's not the error message. I guess the build error is from the changed Menifest.toml. Maybe a Pkg.update() would fix it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the manifest got updated when I included the StatsBase depency for the histogram test in test/randfloat.jl I'll try to clean that.

src/randfloat.jl Outdated
@@ -0,0 +1,73 @@
const Xoroshiro128P = Xorshifts.Xoroshiro128Plus() # use as default RNG for randfloat
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO, the default behavior of randfloat(::Type) should be consistent as those functions in stdlib - using the global MT generator as default. Although it will be much slower, it can correctly reproduce results if users want to, by manually using Random.seed! to set the global state. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a good point, but does RandomNumbers.jl have to be consistent with stdlib? I guess most users (including me) would be happy to just do using RandomNumbers; randfloat(1000) and get something that's faster and higher statistical quality then rand(1000)...?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm, it's also a good point. But if we want to do so, we should better override all default behaviors from stdlib, like rand, randn, etc., i.e., we need to change the global RNG. I don't know if it should be done or if it is even possible.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about using julia's default in randfloat but defining a randfloatx which uses Xoroshiro128Plus?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That sounds still a little weird to me. Please just use the global MT generator for now. I will probably refactor those functions to redefine a default global RNG sometime.

@milankl
Copy link
Contributor Author

milankl commented Jan 27, 2021

Sorry, how do you use Random.default_rng()? It's not <:AbstractRNG which I currently require in randfloat(rng::AbstractRNG... that's why it fails

@milankl
Copy link
Contributor Author

milankl commented Jan 27, 2021

I believe the failure in 1.5 will be fixed with sunoru@235e931, but Random.GLOBAL_RNG wasn't a <:AbstractRNG in 1.0? Sorry, I think I need your input here.

@sunoru
Copy link
Member

sunoru commented Jan 28, 2021

Ah, yes, there's a subtle thing. You need to use Random.AbstractRNG here since I redefined an AbstractRNG in this package.

And you are right I need to merge the other PR first... I don't know why I missed that for so long :(

@milankl
Copy link
Contributor Author

milankl commented Jan 28, 2021

Sorry, that's what I currently have no?

import Random: AbstractRNG, GLOBAL_RNG
function randfloat(rng::AbstractRNG,::Type{Float32})
...
randfloat(::Type{T}=Float64) where T = randfloat(GLOBAL_RNG,T)

@sunoru
Copy link
Member

sunoru commented Jan 28, 2021

I think it should be more explicit like

function randfloat(rng::Random.AbstractRNG,::Type{Float32})

@sunoru
Copy link
Member

sunoru commented Jan 28, 2021

There's also a warning in the testing log showing the import is ignored:
WARNING: import of Random.AbstractRNG into RandomNumbers conflicts with an existing identifier; ignored.

@milankl
Copy link
Contributor Author

milankl commented Jan 28, 2021

Okay sorry, I missed that! Let me remove that line then.

@milankl
Copy link
Contributor Author

milankl commented Jan 28, 2021

Finally 🎉

@sunoru
Copy link
Member

sunoru commented Jan 28, 2021

Nice 🎉

@sunoru sunoru merged commit 3999ece into JuliaRandom:master Jan 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants