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

2008-12-04 Thread Pierre GM

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...
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


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

2008-12-04 Thread Jarrod Millman
On Thu, Dec 4, 2008 at 11:14 AM, Pierre GM [EMAIL PROTECTED] wrote:
 Raise a ValueError (even in 2.5, therefore risking to break something)

+1

-- 
Jarrod Millman
Computational Infrastructure for Research Labs
10 Giannini Hall, UC Berkeley
phone: 510.643.4014
http://cirl.berkeley.edu/
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


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

2008-12-04 Thread josef . pktd
On Thu, Dec 4, 2008 at 2:40 PM, Jarrod Millman [EMAIL PROTECTED] wrote:
 On Thu, Dec 4, 2008 at 11:14 AM, Pierre GM [EMAIL PROTECTED] wrote:
 Raise a ValueError (even in 2.5, therefore risking to break something)

 +1


+1

I'm not yet a serious user of numpy/scipy, but when debugging the
discrete distributions, it took me a while to figure out that some
mysteriously appearing zeros were nans that were silently converted
during casting to int.

In matlab, I encode different types of missing values (in the data) by
numbers that I know are not in my dataset, e.g -2**20, -2**21,... but
that depends on the dataset. (hand made nan handling, before data is
cleaned). When I see then a weird number, I know that there is a
problem, if it the nan is zero, I wouldn't know if it's a missing
value or really a zero.

Josef
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


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

2008-12-04 Thread Pierre GM

On Dec 4, 2008, at 3:24 PM, [EMAIL PROTECTED] wrote:

 On Thu, Dec 4, 2008 at 2:40 PM, Jarrod Millman  
 [EMAIL PROTECTED] wrote:
 On Thu, Dec 4, 2008 at 11:14 AM, Pierre GM [EMAIL PROTECTED]  
 wrote:
 Raise a ValueError (even in 2.5, therefore risking to break  
 something)

 +1


 +1

OK then, I'll do that and update the SVN later tonight or early tmw...
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


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

2008-12-04 Thread Christopher Barker
[EMAIL PROTECTED] wrote:
 Raise a ValueError (even in 2.5, therefore risking to break something)

+1 as well

 it took me a while to figure out that some
 mysteriously appearing zeros were nans that were silently converted
 during casting to int.

and this is why -- a zero is a perfectly valid and useful number, NaN 
should never get cast to a zero (or any other valid number) unless the 
user explicitly asks it to be.

I think the right choice was made for python 2.6 here.

-Chris



-- 
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/ORR(206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115   (206) 526-6317   main reception

[EMAIL PROTECTED]
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


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

2008-11-25 Thread Pierre GM
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) ?

Thanks for any suggestion,
P.
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion