-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Open
Labels
arrays[a, r, r, a, y, s][a, r, r, a, y, s]correctness bug ⚠Bugs that are likely to lead to incorrect results in user code without throwingBugs that are likely to lead to incorrect results in user code without throwingequalityIssues relating to equality relations: ==, ===, isequalIssues relating to equality relations: ==, ===, isequalsortingPut things in orderPut things in order
Description
According to the documentation for isless
,
If
isless(x, y)
is defined, then so isisless(y, x)
andisequal(x, y)
, and exactly one of those three yields true.
My understanding is that this should hold for all possible arguments. However, on 1.9.0-beta4 and master,
julia> using OffsetArrays
julia> x = [1,2,3]; y = OffsetVector(x, -1);
julia> (isless(x,y), isless(y,x), isequal(x,y))
(false, false, false)
This is because isequal(x,y)
gives false
if x
and y
have different index ranges. This is also inconsistent with cmp
,
julia> cmp(x,y)
0
since according to the documentation cmp(x,y) == 0
should imply isequal(x,y)
.
Would it be a solution to define isless(x,y)
and cmp(x,y)
for AbstractVector
only if firstindex(x) == firstindex(y)
and to raise an error otherwise? Or would that be breaking?
Metadata
Metadata
Assignees
Labels
arrays[a, r, r, a, y, s][a, r, r, a, y, s]correctness bug ⚠Bugs that are likely to lead to incorrect results in user code without throwingBugs that are likely to lead to incorrect results in user code without throwingequalityIssues relating to equality relations: ==, ===, isequalIssues relating to equality relations: ==, ===, isequalsortingPut things in orderPut things in order