diff --git a/src/dataarray.jl b/src/dataarray.jl index 59b5abe..aaa60ce 100644 --- a/src/dataarray.jl +++ b/src/dataarray.jl @@ -634,10 +634,11 @@ end #' k = hash(dv) # # TODO: Make sure this agrees with is_equals() -function Base.hash(a::AbstractDataArray) # -> UInt - h = hash(size(a)) + 1 - for i in 1:length(a) - h = hash(@compat(Int(hash(a[i]))), h) +function Base.hash(a::DataArray) # -> UInt + h = hash(a.na) + for i in @compat eachindex(a.data) + # skip NAs (since NAs pattern is already hashed, it's ok) + if !a.na[i] h = hash(a.data[i], h) end end return @compat UInt(h) end diff --git a/test/newtests/dataarray.jl b/test/newtests/dataarray.jl index 7827b93..b97972b 100644 --- a/test/newtests/dataarray.jl +++ b/test/newtests/dataarray.jl @@ -330,4 +330,7 @@ module TestDataArrays hash(DataArray([1, 2], falses(2))) hash(DataArray(repeat([1, 2], outer = [1, 2]), falses(2, 2))) hash(DataArray(repeat([1, 2], outer = [1, 2, 2]), falses(2, 2, 2))) + hash(@data [1, NA]) + hash(@data repeat( [1, 2, NA], outer = [1, 2])) + hash(@data repeat( [NA, NA, NA], outer = [1, 2, 2]), falses(2, 2, 2)) end