Skip to content
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

More restrictive @non_differentiable rand #263

Merged
merged 16 commits into from
Sep 9, 2020
11 changes: 6 additions & 5 deletions test/rulesets/Random/random.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
struct Normal
oxinabox marked this conversation as resolved.
Show resolved Hide resolved
μ
σ
end
Random.rand(d::Normal) = d.μ + d.σ*randn()
oxinabox marked this conversation as resolved.
Show resolved Hide resolved

@testset "random" begin
@testset "MersenneTwister" begin
@testset "no args" begin
Expand Down Expand Up @@ -44,11 +50,6 @@
end

nmheim marked this conversation as resolved.
Show resolved Hide resolved
# Make sure that we do *not* have these set as non_differentiable. as they are differentiable
struct Normal
μ
σ
end
Random.rand(d::Normal) = d.μ + d.σ*randn()
@test frule((Zero(), Normal(0.5,2.0)), rand, Normal(0.1,1.5)) === nothing
oxinabox marked this conversation as resolved.
Show resolved Hide resolved
@test rrule(rand, Normal(0.1,1.5)) === nothing
oxinabox marked this conversation as resolved.
Show resolved Hide resolved
end
Expand Down