-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fallback randn/randexp for AbstractFloat #44714
Conversation
3ca78c1
to
ea151b0
Compare
I did some benchmarks with |
The SparseArrays test checks that How can I update this test given that this is in another repo? |
Hmmm. Maybe first make a PR to SparseArrays.jl to remove that test? And then bump SparseArrays.jl on Julia master. |
# this method is necessary to prevent rand(rng::AbstractRNG, X) from | ||
# recursively constructing nested Sampler types. | ||
Sampler(T::Type{<:AbstractRNG}, sp::Sampler, r::Repetition) = | ||
throw(MethodError(Sampler, (T, sp, r))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that this is a minor change, but a MethodError
seems to be what is really desired here (and is what we normally throw in methods we've only defined to prevent infinite dispatch loops).
(Otherwise, some downstream tests in SparseArrays fail because randn
now falls through to rand
and throws a different error, so this seems like the least-breaking change.)
need to address CI error:
|
Needs #44731 |
5ae06b5
to
ee4d070
Compare
ee4d070
to
70cbd69
Compare
Rebased, so it should include the fix #44731 now. |
Okay to merge? |
Unrelated CI failures. |
This PR adds a fallback
randn
using the Marsaglia polar method (a Box–Muller variant) and a fallbackrandexp
using-log(rand())
so that these two functions work for anyAbstractFloat
type implementingrand(rng, T)
.As noted in #96 (comment), this gives us support for packages like DecFP.jl (closes JuliaMath/DecFP.jl#80) and DoubleFloats.jl for free.
Also closes #17629 for
BigFloat
(though a specialized method ala #35111 should be faster).@andreasnoack, is there a way to test this using https://github.com/JuliaRandom/RNGTest.jl or similar?