Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add rand_tangent for types #172

Merged
merged 5 commits into from
Jun 8, 2021
Merged

Add rand_tangent for types #172

merged 5 commits into from
Jun 8, 2021

Conversation

mzgubic
Copy link
Member

@mzgubic mzgubic commented Jun 8, 2021

So far

julia> ChainRulesTestUtils.rand_tangent(Float64)
ERROR: StackOverflowError:
Stacktrace:
     [1] rand_tangent(rng::Random._GLOBAL_RNG, x::Module)
       @ FiniteDifferences ~/JuliaEnvs/ChainRulesTestUtils.jl/dev/FiniteDifferences/src/rand_tangent.jl:50
     [2] (::FiniteDifferences.var"#3#5"{Random._GLOBAL_RNG, Core.TypeName})(field_name::Symbol)
       @ FiniteDifferences ~/JuliaEnvs/ChainRulesTestUtils.jl/dev/FiniteDifferences/src/rand_tangent.jl:51
     [3] map (repeats 2 times)
       @ ./tuple.jl:216 [inlined]
     [4] rand_tangent(rng::Random._GLOBAL_RNG, x::Core.TypeName)
       @ FiniteDifferences ~/JuliaEnvs/ChainRulesTestUtils.jl/dev/FiniteDifferences/src/rand_tangent.jl:50
     [5] (::FiniteDifferences.var"#3#5"{Random._GLOBAL_RNG, DataType})(field_name::Symbol)
       @ FiniteDifferences ~/JuliaEnvs/ChainRulesTestUtils.jl/dev/FiniteDifferences/src/rand_tangent.jl:51
     [6] map(f::FiniteDifferences.var"#3#5"{Random._GLOBAL_RNG, DataType}, t::NTuple{20, Symbol})
       @ Base ./tuple.jl:226
     [7] rand_tangent(rng::Random._GLOBAL_RNG, x::Type{Float64})
       @ FiniteDifferences ~/JuliaEnvs/ChainRulesTestUtils.jl/dev/FiniteDifferences/src/rand_tangent.jl:50
     [8] (::FiniteDifferences.var"#3#5"{Random._GLOBAL_RNG, Core.TypeName})(field_name::Symbol)
       @ FiniteDifferences ~/JuliaEnvs/ChainRulesTestUtils.jl/dev/FiniteDifferences/src/rand_tangent.jl:51
--- the last 6 lines are repeated 4152 more times ---
 [24921] map (repeats 4 times)
       @ ./tuple.jl:216 [inlined]
 [24922] rand_tangent(rng::Random._GLOBAL_RNG, x::Core.TypeName)
       @ FiniteDifferences ~/JuliaEnvs/ChainRulesTestUtils.jl/dev/FiniteDifferences/src/rand_tangent.jl:50
 [24923] (::FiniteDifferences.var"#3#5"{Random._GLOBAL_RNG, DataType})(field_name::Symbol)
       @ FiniteDifferences ~/JuliaEnvs/ChainRulesTestUtils.jl/dev/FiniteDifferences/src/rand_tangent.jl:51
 [24924] map(f::FiniteDifferences.var"#3#5"{Random._GLOBAL_RNG, DataType}, t::NTuple{20, Symbol})
       @ Base ./tuple.jl:226
 [24925] rand_tangent(rng::Random._GLOBAL_RNG, x::Type{Float64})
       @ FiniteDifferences ~/JuliaEnvs/ChainRulesTestUtils.jl/dev/FiniteDifferences/src/rand_tangent.jl:50
 [24926] rand_tangent(x::Type)
       @ FiniteDifferences ~/JuliaEnvs/ChainRulesTestUtils.jl/dev/FiniteDifferences/src/rand_tangent.jl:8

with this

julia> ChainRulesTestUtils.rand_tangent(Float64)
NoTangent()

Needed for JuliaDiff/ChainRulesTestUtils.jl#117

@@ -57,3 +57,6 @@ function rand_tangent(rng::AbstractRNG, x::T) where {T}
Tangent{T}(; NamedTuple{field_names}(tangents)...)
end
end

rand_tangent(rng::AbstractRNG, ::Type) = NoTangent()
rand_tangent(rng::AbstractRNG, ::Module) = NoTangent()
Copy link
Member Author

Choose a reason for hiding this comment

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

This is needed to work on Julia 1.0

Co-authored-by: Lyndon White <oxinabox@ucc.asn.au>
@mzgubic mzgubic merged commit 91d6652 into master Jun 8, 2021
mzgubic pushed a commit that referenced this pull request Jun 9, 2021
mzgubic pushed a commit that referenced this pull request Jun 9, 2021
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants