[Numpy-discussion] numpy and unittests

Christian Meesters meesters at uni-mainz.de
Mon Aug 7 12:29:44 CDT 2006


I used to work with some unittest scripts for a bigger project of mine. Now 
that I started the project again the tests don't work anymore, using numpy 
version '' .

The errors I get look are like this:

ERROR: _normalize() should return dataset scaled between 0 and 1
Traceback (most recent call last):
  File "testingSAXS.py", line 265, in testNormalization
  File "/usr/lib64/python2.4/unittest.py", line 332, in failUnlessEqual
    if not first == second:
line 174, in __eq__
    if self.intensity == other.intensity:
ValueError: The truth value of an array with more than one element is 
ambiguous. Use a.any() or a.all()

The 'self.intensity' objects are 1D-arrays containing integers <= 1E6.

The unittest script looks like:

if __name__=='__main__':
    from Data import *
    from Utils import *
    import unittest

    def test__eq__(self):
            """__eq__ should return True with identical array data"""
            self.assert_(self.test1 == self.test2)
    suite = unittest.TestSuite()

Any ideas what I have to change? (Possibly trivial, but I have no clue.)


More information about the Numpy-discussion mailing list