More restrictive @non_differentiable rand - #263
Conversation
|
Why not just add: ?
It could also be added with varargs directly, without using the macro. |
|
Oh i was confused by the title. |
| @non_differentiable rand(::Int, ::Int) | ||
| @non_differentiable rand(::Int, ::Int, ::Int) | ||
| @non_differentiable rand(::Int, ::Int, ::Int, ::Int) | ||
| @non_differentiable rand(::Int, ::Int, ::Int, ::Int, ::Int) |
There was a problem hiding this comment.
I think all the Int should be Integer
to match:
[69] rand(X, d::Integer, dims::Integer...) in Random at /usr/local/src/julia/julia-1.5/usr/share/julia/stdlib/v1.5/Random/src/Random.jl:283
|
Can we add a test that makes sure |
|
I think we might also in particular want: @non_differentiable rand(::AbstractRNG, ::Random.Sampler)
@non_differentiable rand(::AbstractRNG, ::Tuple) |
|
Let me know what you think about my take on testing the new rules. I am really not sure if this is how it should be done. Especially because the |
oxinabox
left a comment
There was a problem hiding this comment.
Nice.
A few suggestions,
once those are addressed and the version number bumped we can merge this and tag a release
willtebbutt
left a comment
There was a problem hiding this comment.
Just a couple of style things.
Once @oxinabox 's suggestions and these are attended to, please bump the patch version and we'll merge when tests pass :)
Thanks for the contribution -- it's much appreciated!
|
Great, thanks for the suggestions! I think the tests are failing because of something unrelated to this PR though... they also fail in #261 because of something |
Co-authored-by: willtebbutt <wt0881@my.bristol.ac.uk>
Co-authored-by: Lyndon White <oxinabox@ucc.asn.au>
Oh, yeah, don't worry about the Zygote integration tests -- Zygote master is currently broken. |
|
Actually, I am not sure about the comment on the test of the "differentiable" cases. |
Yes. |
nmheim
left a comment
There was a problem hiding this comment.
I am sorry, but I am a bit clueless how to test the rules on fields of a struct if they don't appear in the rand function call... this is probably not how it should be done...
oxinabox
left a comment
There was a problem hiding this comment.
I am going to add my suggestions and then if i didn't break CI merge this
|
Awesome, thank you! :) |
Addresses #262. I am really not sure if this is a good approach because there are quite a few different
randmethods...This is what works with the use cases I have. What are the most common uses of
randthat should be non-differentiable?