[Numpy-discussion] using assertEqual in unittest to test two np.ndarray?

Grissiom chaos.proton@gmail....
Fri Mar 20 07:15:50 CDT 2009

Hi all,

When I try to use assertEqual in unittest to test my numpy codes I got this:

ERROR: test_test (__main__.Test_data_ana)
Traceback (most recent call last):
  File "./unit_test.py", line 24, in test_test
    [4, 5, 6]]))
  File "/usr/lib/python2.5/unittest.py", line 332, in failUnlessEqual
    if not first == second:
ValueError: The truth value of an array with more than one element is
ambiguous. Use a.any() or a.all()

Ran 2 tests in 0.003s

FAILED (errors=1)

I know I should use array_equal to test two arrays but it will be more
convenient to implement it as __eq__. Any hints? Thanks in advance.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20090320/bd279aee/attachment-0001.html 

More information about the Numpy-discussion mailing list