Sunday, 8 September 2013

Why is there different behavior with short-hand assignment and NaN?

Why is there different behavior with short-hand assignment and NaN?

I see this in python 2.7.3, with both pylab and numpy. Why is this:
>>> x = pylab.arange(5)
>>> x = x + pylab.nan
>>> print x
[ nan nan nan nan nan]
different than this:
>>> x = pylab.arange(5)
>>> x += pylab.nan
__main__:1: RuntimeWarning: invalid value encountered in add
>>> print x
[-9223372036854775808 -9223372036854775808 -9223372036854775808
-9223372036854775808 -9223372036854775808]
?

No comments:

Post a Comment