-
Notifications
You must be signed in to change notification settings - Fork 62
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
Comparison tests ZeroTangent with 0-like numbers should be true #504
Comments
Yes, though we use julia> using ChainRulesTestUtils
julia> test_approx(ZeroTangent(), 0)
Test Passed
julia> test_approx(ZeroTangent(), zeros(2, 3))
Test Passed |
indeed good point. Could it be worth it to have it somewhere close to the ZeroTangent doc? |
I would argue it belongs to the ChainRulesTestUtils docs, but we could certainly add a link to those. |
What's the argument against defining these? Besides being one less thing to know about, Maybe array ones are weird, in that Finally, |
yes I wasn't sure about arrays, I found |
I think the reason we have compare: julia> using ChainRulesCore
julia> using ChainRulesTestUtils
julia> using Test
julia> struct Foo end
julia> unfoo(x) = x
unfoo (generic function with 1 method)
julia> unfoo(f::Foo) = 0.0
unfoo (generic function with 2 methods)
julia> Base.isapprox(f::Foo, b) = isapprox(unfoo(f), b)
julia> @test Foo() ≈ 0.1
Test Failed at REPL[11]:1
Expression: Foo() ≈ 0.1
Evaluated: Foo() ≈ 0.1
ERROR: There was an error during testing to julia> using ChainRulesCore
julia> using ChainRulesTestUtils
julia> using Test
julia> struct Foo end
julia> unfoo(f::Foo) = 0.0
unfoo (generic function with 1 method)
julia> unfoo(x) = x
unfoo (generic function with 2 methods)
julia> ChainRulesTestUtils.test_approx(f::Foo, b) = test_approx(unfoo(f), b)
julia> test_approx(Foo(), 0.1)
Test Failed at /Users/mzgubic/JuliaEnvs/ChainRulesTestUtils.jl/src/check_result.jl:24
Expression: isapprox(actual, expected; kwargs...)
Evaluated: isapprox(0.0, 0.1)
ERROR: There was an error during testing |
We used to define I suspect it is also pretty invalidating, if we define it in CRC, but I haven't tested that. |
Was just testing something boiling down to:
ZeroTangent() ≈ 0
Should this be accepted? Along with arrays for which the norm is 0?
The text was updated successfully, but these errors were encountered: