Julia: replace `@test_approx_eq_eps` with another idiom

Created on 6 Jan 2017  Â·  9Comments  Â·  Source: JuliaLang/julia

Part of https://github.com/JuliaLang/julia/issues/4615. Now that @test_approx_eq has been deprecated and removed from our test suite, the next step is to replace all uses of @test_approx_eq_eps from the test suite and deprecate that macro in a similar fashion. Possible replacement for @test_approx_eq_eps a b É›:

@test ≈(a, b, atol = ɛ)

I kind of wish there was a nicer way to write that, but I'm not sure that there is.

help wanted testsystem

Most helpful comment

abs is no longer automatically vectorized and < never has been, so it would have to be more like:

@test maximum(abs, a - b) < É›

Perhaps that's better since it's far more explicit about what the test is actually checking.

All 9 comments

@test abs(a - b) < É› ?

One idea: change the @test macro (and @test_{throws,broken,skip} too) to accept zero or more trailing arguments of the form x=y which, if the test if a call form, are passed as keyword arguments to the call, even when it's not expressed using call syntax. That would allow writing:

@test a ≈ b atol=ɛ

abs is no longer automatically vectorized and < never has been, so it would have to be more like:

@test maximum(abs, a - b) < É›

Perhaps that's better since it's far more explicit about what the test is actually checking.

Or maybe reduce(maxabs, a - b)?

norm?

We also deprecated maxabs, so that won't work either.

norm might be the right thing to check, but that's certainly not what the tests currently do, so that would not be a straightforward search-and-replace by any means.

Would @test isapprox(a, b, atol=ɛ) not suffice? It's just the tolerance-provided version of ≈, which we're already using in place of @test_approx_eq.

Yes, I was just proposing a slightly nicer syntax for that kind of thing. Not sure if it's worth it.

Was this page helpful?
0 / 5 - 0 ratings