Skip to content

Commit

Permalink
fix unique over a dimension to use isequal over == (#42737)
Browse files Browse the repository at this point in the history
  • Loading branch information
KristofferC authored Oct 21, 2021
1 parent dc46ad9 commit 011fda9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions base/multidimensional.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1666,7 +1666,7 @@ _unique_dims(A::AbstractArray, dims::Colon) = invoke(unique, Tuple{Any}, A)
else
j_d = i_d
end) begin
if (@nref $N A j) != (@nref $N A i)
if !isequal((@nref $N A j), (@nref $N A i))
collided[k] = true
end
end
Expand Down Expand Up @@ -1696,7 +1696,7 @@ _unique_dims(A::AbstractArray, dims::Colon) = invoke(unique, Tuple{Any}, A)
j_d = i_d
end
end begin
if (@nref $N A j) != (@nref $N A i)
if !isequal((@nref $N A j), (@nref $N A i))
nowcollided[k] = true
end
end
Expand Down
4 changes: 4 additions & 0 deletions test/arrayops.jl
Original file line number Diff line number Diff line change
Expand Up @@ -791,6 +791,10 @@ let A, B, C, D

# With hash collisions
@test map(x -> x.x, unique(map(HashCollision, B), dims=1)) == C

# With NaNs:
E = [1 NaN 3; 1 NaN 3; 1 NaN 3];
@test isequal(unique(E, dims=1), [1 NaN 3])
end

@testset "large matrices transpose" begin
Expand Down

0 comments on commit 011fda9

Please sign in to comment.