Skip to content
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

should we use == or === in tests? #4

Open
lucaferranti opened this issue May 31, 2021 · 3 comments
Open

should we use == or === in tests? #4

lucaferranti opened this issue May 31, 2021 · 3 comments

Comments

@lucaferranti
Copy link
Member

lucaferranti commented May 31, 2021

In the latest commit I switched to use === instead of ==, mainly because the comparison of decorated intervals ignores the decoration part. This helped revealing a couple of bugs that have been silent in IntervalArithmetic so far, e.g.

julia> DecoratedInterval(-Inf..Inf, com)
[-∞, ∞]_com

As a downside, since 0.0 === -0.0 evaluates to false, now a few more tests fail, e.g.

julia> @test +(interval(-0.0,2.0)) === Interval(0.0,2.0)
Test Failed at REPL[36]:1
  Expression: +(interval(-0.0, 2.0)) === Interval(0.0, 2.0)
   Evaluated: [-0, 2] === [0, 2]
ERROR: There was an error during testing

julia> @test +(interval(-0.0, 2.0)) == Interval(0.0, 2.0)
Test Passed

I am not sure what the standard says about +0.0 vs -0.0, so I am not sure what to think about this.

One alternative would be to modify the parser so that whenever it encounters an expression in the form something == DecoratedInterval(something) then it creates the test
something == DecoratedInterval(something) && decoration(something) == decoration(DecoratedInterval(something))

@Kolaru
Copy link

Kolaru commented Dec 13, 2021

Among other things in JuliaIntervals/IntervalArithmetic.jl#271, I plan to introduce a new symbol for interval equality (X ≛ Y) to represent isEqual as defined in the standard.

This should solve the problem you have here as well.

@dpsanders
Copy link
Member

I think -0.0 should be normalized to 0.0 when it's a lower bound, and maybe vice versa when it's an upper bound.

@lbenet
Copy link
Member

lbenet commented Dec 14, 2021

Now that #500 is merged, can we check again if things are now working with ===?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants