[Numpy-discussion] different behaviour in asfarray(None)

Travis E. Oliphant oliphant at enthought.com
Tue Apr 22 18:00:04 EDT 2008


Stéfan van der Walt wrote:
> 2008/4/22 lorenzo bolla <lbolla at gmail.com>:
>   
>> I noticed a change in the behaviour of numpy.asfarray between numpy version
>> 1.0.5 and 1.1.0:
>>
>> 1.0.5
>> ====
>>
>> In [3]: numpy.asfarray(None)
>> Out[3]: array(nan)
>> In [4]: numpy.__version__
>> Out[4]: '1.0.5.dev4455'
>>
>> 1.1.0
>> ====
>>
>> In [16]: numpy.asfarray(None)
>> ---------------------------------------------------------------------------
>> <type 'exceptions.TypeError'>: float() argument must be a string or a number
>>
>> Is this intended? why?
>>     
>
> Yes, 'asfarray' is equivalent to
>
> array(input).astype(dtype)
>
> I think it would be wrong to assume that None means NaN.
>   
I'm curious who made the change and why.  There was code intentionally 
there to interpret None as nan for float arrays.   So, I don't 
understand why and/or when it changed.

-Travis




More information about the NumPy-Discussion mailing list