[Numpy-discussion] in(np.nan) on python 2.6

Pierre GM pgmdevlist@gmail....
Thu Dec 4 13:14:52 CST 2008


On Nov 25, 2008, at 12:23 PM, Pierre GM wrote:

> All,
> Sorry to bump my own post, and I was kinda threadjacking anyway:
>
> Some functions of numy.ma (eg, ma.max, ma.min...) accept explicit  
> outputs that may not be MaskedArrays.
> When such an explicit output is not a MaskedArray, a value that  
> should have been masked is transformed into np.nan.
>
> That worked great in 2.5, with np.nan automatically transformed to 0  
> when the explicit output had a int dtype. With Python 2.6, a  
> ValueError is raised instead, as np.nan can no longer be casted to  
> int.
>
> What should be the recommended behavior in this case ? Raise a  
> ValueError or some other exception, to follow the new Python2.6  
> convention, or silently replace np.nan by some value acceptable by  
> int dtype (0, or something else) ?


Second bump, sorry. Any consensus on what the behavior should be ?  
Raise a ValueError (even in 2.5, therefore risking to break something)  
or just go with the flow and switch np.nan to an acceptable value  
(like 0), under the hood ? I'd like to close the corresponding ticket...


More information about the Numpy-discussion mailing list