-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Deprecate @test_approx_eq
(part of #4615)
#19880
Conversation
Is there a non unicode way to do this? |
|
They're not 100% equivalent yet, though. julia> @test_approx_eq 2.1 1+1
ERROR: assertion failed: |2.1 - 1 + 1| <= 4.440892098500626e-12
2.1 = 2.1
1 + 1 = 2
difference = 0.10000000000000009 > 4.440892098500626e-12
in test_approx_eq(::Float64, ::Int64, ::Float64, ::String, ::String) at ./test.jl:863
in test_approx_eq(::Float64, ::Int64, ::String, ::String) at ./test.jl:873
julia> @test isapprox(2.1, 1+1)
Test Failed
Expression: isapprox(2.1,1 + 1)
ERROR: There was an error during testing
in record(::Base.Test.FallbackTestSet, ::Base.Test.Fail) at ./test.jl:397
in do_test(::Base.Test.Returned, ::Expr) at ./test.jl:281
julia> @test 2.1 ≈ 1+1
Test Failed
Expression: 2.1 ≈ 1 + 1
Evaluated: 2.1 isapprox 2
ERROR: There was an error during testing
in record(::Base.Test.FallbackTestSet, ::Base.Test.Fail) at ./test.jl:397
in do_test(::Base.Test.Returned, ::Expr) at ./test.jl:281 |
:(test_approx_eq($(esc(a)), $(esc(b)), $(string(a)), $(string(b)))) | ||
end | ||
export @test_approx_eq |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we do this with an eval into the Base.Test
module from deprecated.jl
so it's in a place where we know we'll be deleting it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Eh, I'd rather just leave it here until we tear out the rest of this stuff.
Fair point, @cstjean. We could check in |
We display lots of test conditions specially, so that could certainly be arranged for |
|
||
As calculations on floating-point values can be imprecise, you can perform approximate equality | ||
checks using either `@test a ≈ b` (where `≈`, typed via tab completion of `\approx`, is the | ||
[`isapprox()`](@ref) function) or use [`isapprox()`](@ref) directly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This first paragraph seems fine to leave in. Same with the examples that use isapprox
, and the ```@docs
line for @inferred
in expression: 1 ≈ 0.999999 | ||
in error at error.jl:21 | ||
in default_handler at test.jl:30 | ||
in do_test at test.jl:53 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these 2 were worth keeping (though should be made into doctests if possible)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you open an issue for it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
about to get on a plane (aren't you, too?), I have a commit on a misc branch locally to put these back, can go into a PR next time I rearrange branches
|
I think I'd prefer to have that as a feature of isapprox than keep this weird extra testing API around. |
I just wanted to point out a difference between I was testing a custom type and in |
@test_approx_eq_eps
, you're next!