For my unittest, I want to check if two arrays are identical. Reduced example:
a = np.array([1, 2, np.NaN])
b = np.array([1, 2, np.NaN])
if np.all(a==b):
print 'arrays are equal'
This does not work because nan != nan
.
What is the best way to proceed?
Alternatively you can use
numpy.testing.assert_equal
ornumpy.testing.assert_array_equal
with atry/except
:Edit
Since you are using this for unittesting, bare
assert
(instead of wrapping it to getTrue/False
) might be more natural.