Numeric array in unittest problem

Robert Kern robert.kern at gmail.com
Mon Nov 21 17:07:30 CET 2005


ajikoe at gmail.com wrote:
> hello,
> 
> I found that if I use Numeric.array into unittest it is not
> consistance,
> Is that normal ?
> 
> import Numeric
> class myTest(unittest.TestCase):
>     def runTest(self):
>         a = Numeric.array([1,2])
>         b = Numeric.array([1,33])
>         self.assertEqual(a, b)
>     pass
> 
> 
> This will not raise any error ???
> 
> Any idea?

unittest.TestCase.assertEqual() uses == to compare a and b. Numeric
arrays have rich comparisons and so return arrays, not booleans. Try it
in the interpreter. To get a boolean from a==b, use Numeric.alltrue(a==b).

-- 
Robert Kern
robert.kern at gmail.com

"In the fields of hell where the grass grows high
 Are the graves of dreams allowed to die."
  -- Richard Harter




More information about the Python-list mailing list