ChainRulesTestUtils.jl icon indicating copy to clipboard operation
ChainRulesTestUtils.jl copied to clipboard

more `test_approx` ambiguities

Open lukas-weber opened this issue 11 months ago • 0 comments

test_approx(Tangent{Float64}(), ZeroTangent())
test_approx(ZeroTangent(), Tangent{Float64}())

Fails due to method ambiguities.

ERROR: MethodError: test_approx(::Tangent{Float64, @NamedTuple{}}, ::ZeroTangent) is ambiguous.

Candidates:
  test_approx(actual::Tangent{P, T}, expected; ...) where {T, P}
    @ ChainRulesTestUtils /home/lweber/.julia/packages/ChainRulesTestUtils/Ko1Wr/src/check_result.jl:124
  test_approx(x, ::AbstractZero; ...)
    @ ChainRulesTestUtils /home/lweber/.julia/packages/ChainRulesTestUtils/Ko1Wr/src/check_result.jl:43

Possible fix, define
  test_approx(::Tangent{P, T}, ::AbstractZero) where {T, P}

Stacktrace:
 [1] top-level scope
   @ REPL[7]:1

The equivalent with NoTangent() works.

lukas-weber avatar Feb 28 '25 16:02 lukas-weber