[SciPy-user] NaN's in numpy (and Scipy)

Vincent Nijs v-nijs at kellogg.northwestern.edu
Sat Jan 6 17:47:28 CST 2007

I see. But when you assign a float (e.g., nan or 0.1) to an element of an
array filled with 'int16' elements the array is not up-cast but the element

Thanks for the clarification!


On 1/6/07 4:28 PM, "A. M. Archibald" <peridot.faceted at gmail.com> wrote:

> On 06/01/07, Vincent Nijs <v-nijs at kellogg.northwestern.edu> wrote:
>> It may be relevant to note that 'isnan' only seems to work with floats. If
>> you change Pierre's example a bit, mask creation doesn't work as I might
>> expect. If you create the array as follows
>>>>> x = N.array([1,2,N.nan,4],dtype='int16')
> [...]
>> It might be convenient if an array would be automatically up-cast to float
>> is an nan is present.
> This is in fact the normal behaviour of numpy: if there's a
> floating-point number in the array when you create it, the array gets
> upcast - unless you specify the data type, forcing it to a particular
> type. Which you did.
> The unavailablity of NaNs for integer types is sometimes unfortunate,
> but there's really nothing numpy can do about it.
> A. M. Archibald
> _______________________________________________
> SciPy-user mailing list
> SciPy-user at scipy.org
> http://projects.scipy.org/mailman/listinfo/scipy-user

More information about the SciPy-user mailing list