-
-
Notifications
You must be signed in to change notification settings - Fork 17
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
Base.isless(u::AbstractInterval, v::AbstractInterval) may create confusing ordering for IntervalValue #36
Comments
Closing as this is interval ordering and pure number ordering may not apply. This will be a case of partial ordering. I will reopen if I can prove otherwise. |
This may be a bit of a details since I worked on it I will like to just write it down for future reference. The behavior as defined is correct and matches to Julia fallback of operators of 0.6 but not 0.7. Considering two intervals:
Now we want to see if:
While mathematical trichotomy is preserved at an abstract type level in case of IntervalValue additional
|
ec83e2a provides a detailed description of the problem. The solution provided was to convert every comparison where
I also tried to impress upon the Julia community to bring back the 0.6 behavior but it does not seem the community is really keen on that. Hence, reopening this bug. https://discourse.julialang.org/t/behavior-of-when-isless-or-is-defined/10114/21 |
One last usecase in the code below (first(u) == first(v)) :
May fail if it may be safer to write
or expect the caller to implement |
Will it help things to restrict T in |
@benjward that will work for Integer types as well. As |
Give me all the words btw "aa" to "cd" in the English dictionary is a good interval example with |
The solution I'm inclined towards is to use custom comparison functions within the package. That is, instead of defining Upsides:
Downsides:
It's possible I'm overlooking some use case where it's important for the data structure to obey a custom ordering, but I think it's more trouble than it's worth, and we should just banish them. I'm happy to go ahead and try this out. I want to do some tinkering anyway. |
@dcjones If you make a PR, can you make it to the version-1.0 branch? I'm setting up version-1.0 branches across BioJulia packages to incorporate any julia version 0.7/1.0 related changes now and to drop julia 0.6. This is so as to encourage use of the latest julia, especially as it is the language hitting 1.0. |
Since,
Base.isless(u::AbstractInterval, v::AbstractInterval)
is defined, the same will propagate down toIntervalValue
.Technically,
isequal(u, v)
should be similar to!isless(u, v) && !isless(v, u)
.But,
isequal(u::IntervalValue, v::IntervalValue)
will take into consideration theu.value
andv.value
parameters. This may lead to anomalous behavior in some cases. Like if you are usingcmp(u, v)
for example.The text was updated successfully, but these errors were encountered: