[Numpy-discussion] Ticket #794 and can o' worms.

Charles R Harris charlesr.harris@gmail....
Sun Jul 20 17:42:42 CDT 2008

Hi All,

I "fixed" ticket #754, but it leads to a ton of problems. The original
discussion is here<http://thread.gmane.org/gmane.comp.python.numeric.general/21526/focus=21537>.
The problems that arise come from conversion to different types.

In [26]: a
Out[26]: array([ Inf, -Inf,  NaN,   0.,   3.,  -3.])

In [27]: sign(a).astype(int)
array([          1,          -1, -2147483648,           0,           1,

In [28]: sign(a).astype(bool)
Out[28]: array([ True,  True,  True, False,  True,  True], dtype=bool)

In [29]: sign(a)
Out[29]: array([  1.,  -1.,  NaN,   0.,   1.,  -1.])

In [30]: bool(NaN)
Out[30]: True

So there are problems with at minimum the following.

1) The way NaN is converted to bool. I think it should be False.
2) The way NaN is converted to int types. I think it should be 0.

These problems show up in failing tests. I'm reverting the fix for now, but
I wonder what we should do about these things.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20080720/d85994a6/attachment.html 

More information about the Numpy-discussion mailing list