How to check if two arrays are equal even if they contain NaN values in Julia?

Use isequal:

Similar to ==, except for the treatment of floating point numbers and of missing values. isequal treats all floating-point NaN values as equal to each other, treats -0.0 as unequal to 0.0, and missing as equal to missing. Always returns a Bool value.

julia> a = [1,2, NaN]
3-element Array{Float64,1}:
   1.0
   2.0
 NaN  

julia> b = [1,2, NaN]
3-element Array{Float64,1}:
   1.0
   2.0
 NaN  

julia> isequal(a, b)
true

You probably want to use isequal(a, b) (which also treats missing equal to missing, but -0.0 as unequal to 0.0).

Tags:

Julia