correct Numeric behavior?

Rick Ree rick at bioinformatics.org
Sun Apr 21 20:16:15 EDT 2002


The following seems counterintuitive:

>>> import Numeric
>>> a = Numeric.array([0])
>>> a
array([0])
>>> not a
1
>>> b = Numeric.array([1])
>>> not b
0

That is, a rank-1 array if length 1 tests false if it's value is 0,
but true otherwise.  This is not the case with the array module:

>>> import array
>>> x = array.array("i", [0])
>>> x
array('i', [0])
>>> not x
0

Is this the intended behavior of Numeric, or is this a bug?



More information about the Python-list mailing list