Skip to content

test_approx has ambiguities #229

Open
@mcabbott

Description

@mcabbott
julia> ChainRulesTestUtils.test_approx(Tangent{Int}(; x=1), ZeroTangent())
ERROR: MethodError: test_approx(::Tangent{Int64, NamedTuple{(:x,), Tuple{Int64}}}, ::ZeroTangent) is ambiguous. Candidates:
  test_approx(x, ::AbstractZero) in ChainRulesTestUtils at /Users/me/.julia/packages/ChainRulesTestUtils/8dFTY/src/check_result.jl:34
  test_approx(actual::Tangent{P, T}, expected) where {T, P} in ChainRulesTestUtils at /Users/me/.julia/packages/ChainRulesTestUtils/8dFTY/src/check_result.jl:108
Possible fix, define
  test_approx(::Tangent{P, T}, ::AbstractZero) where {T, P}
Stacktrace:

That's a made-up example, the real one gave:

Error During Test at /Users/me/.julia/packages/ChainRulesTestUtils/8dFTY/src/testers.jl:195
  Got exception outside of a @test
  MethodError: (::ChainRulesTestUtils.var"#test_approx##kw")(::NamedTuple{(:rtol, :atol), Tuple{Float64, Float64}}, ::typeof(test_approx), ::ChainRulesCore.NoTangent, ::ChainRulesCore.Tangent{Tuple{Float64, Float64, Float64}, Tuple{Float64, Float64, Float64}}) is ambiguous. Candidates:
    (var"#s103"::ChainRulesTestUtils.var"#test_approx##kw")(::Any, ::typeof(test_approx), x, y::ChainRulesCore.Tangent) in ChainRulesTestUtils at /Users/me/.julia/packages/ChainRulesTestUtils/8dFTY/src/check_result.jl:124
    (var"#s102"::ChainRulesTestUtils.var"#test_approx##kw")(::Any, ::typeof(test_approx), ::ChainRulesCore.AbstractZero, x) in ChainRulesTestUtils at /Users/me/.julia/packages/ChainRulesTestUtils/8dFTY/src/check_result.jl:33
  Possible fix, define
    (::ChainRulesTestUtils.var"#test_approx##kw")(::Any, ::typeof(test_approx), ::ChainRulesCore.AbstractZero, ::ChainRulesCore.Tangent)

Real example: https://github.com/JuliaDiff/ChainRules.jl/pull/570/files#diff-14d216cb53721d9360bbbcc399d93fff67f2594bd388162abbbe82c59ad1ba9fR169

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions