[Numpy-discussion] numpy and unittests

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


Hi,

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 '0.9.5.2100' .

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
    
self.assertEqual(self.test1._normalize(minimum=0.0,maximum=1.0),self.test5)
  File "/usr/lib64/python2.4/unittest.py", line 332, in failUnlessEqual
    if not first == second:
  File 
"/home/cm/Documents/Informatics/Python/python_programming/biophysics/SAXS/lib/Data.py", 
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

<snip>
    def test__eq__(self):
            """__eq__ should return True with identical array data"""
            self.assert_(self.test1 == self.test2)
<snip>
    suite = unittest.TestSuite()
    suite.addTest(unittest.makeSuite(Test_SAXS_Sanity))
<snip>
    unittest.TextTestRunner(verbosity=1).run(suite) 

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

TIA
Cheers
Christian




More information about the Numpy-discussion mailing list