[Numpy-discussion] using assertEqual in unittest to test two np.ndarray?
Pierre GM
pgmdevlist@gmail....
Fri Mar 20 15:49:19 CDT 2009
On Mar 20, 2009, at 4:39 PM, Christopher Barker wrote:
> Grissiom wrote:
>> I know I should use array_equal to test two arrays
>
> Not answering your question, but I hadn't known about array_equal, so
> when I saw this, I thought: great! I can get rid of a bunch of ugly
> code
> in my tests. However, it doesn't work as I would like for NaNs:
Chris, have you tried assert_equal redefined in numpy.ma.testutils ?
It was deisgned for masked arrays, but automatically deals with NaNs
>>> from numpy.ma.testutils import assert_equal
>>> a = np.array([1,2,np.nan,4])
>>> assert_equal(a,a)
More information about the Numpy-discussion
mailing list