Numeric array in unittest problem
Robert Kern
robert.kern at gmail.com
Mon Nov 21 12:59:18 EST 2005
Alex Martelli wrote:
>>>>import Numeric
>>>>a=Numeric.array([1,22])
>>>>b=Numeric.array([1,33])
>>>>c = a==b
>>>>c
>
> array([1, 0])
>
>>>>assert(c)
>
> i.e., thanks to element-by-element evaluation, == will generally return
> a true value for ANY comparison of Numeric arrays, causing a very
> frequent beginner's bug to be sure.
Indeed. This is why numarray and scipy_core have made arrays raise an
exception when someone tries to use them as truth values.
--
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