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

a vector is always == to itself, even when containing missing #34744

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions base/abstractarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1776,6 +1776,7 @@ end
isless(A::AbstractVector, B::AbstractVector) = cmp(A, B) < 0

function (==)(A::AbstractArray, B::AbstractArray)
A === B && return true
if axes(A) != axes(B)
return false
end
Expand Down
1 change: 1 addition & 0 deletions base/operators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ in which case `missing` is returned
([three-valued logic](https://en.wikipedia.org/wiki/Three-valued_logic)).
For collections, `missing` is returned if at least one of the operands contains
a `missing` value and all non-missing values are equal.
An exception is when both operands are the same object.
Use [`isequal`](@ref) or [`===`](@ref) to always get a `Bool` result.

# Implementation
Expand Down
6 changes: 6 additions & 0 deletions test/arrayops.jl
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,13 @@ using Dates
@test Array(a) !== a
@test Array{eltype(a)}(a) !== a
@test Vector(a) !== a

# missing
a = [missing]
@test ismissing(a == [missing])
@test a == a
end

@testset "reshaping SubArrays" begin
a = Array(reshape(1:5, 1, 5))
@testset "linearfast" begin
Expand Down
2 changes: 2 additions & 0 deletions test/dict.jl
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,8 @@ end
@test Dict(NaN=>1) == Dict(NaN=>1)
@test isequal(Dict(NaN=>1), Dict(NaN=>1))

d = Dict(1=>missing)
@test d == d
@test ismissing(Dict(1=>missing) == Dict(1=>missing))
@test isequal(Dict(1=>missing), Dict(1=>missing))

Expand Down