Re: [Numpy-discussion] Behavior of nan{max, min} and nanarg{max, min} for all-nan slices.

2013-10-04 Thread Charles R Harris
I've made a PR for this. The commit message is Deal with subclasses of ndarray, like pandas.Series and matrix. Subclasses may not define the new keyword keepdims or deal gracefully with ufuncs in all their forms. This is solved by throwing the problem onto the np.sum,

Re: [Numpy-discussion] Behavior of nan{max, min} and nanarg{max, min} for all-nan slices.

2013-10-03 Thread Daniele Nicolodi
Hello, sorry, I don't know where exactly jump in in the thread, it is getting quite long and articulated... On 02/10/2013 21:19, Charles R Harris wrote: The main problem I had was deciding what arg{max, min} should return as the return value is an integer. I like your suggestion of returning

Re: [Numpy-discussion] Behavior of nan{max, min} and nanarg{max, min} for all-nan slices.

2013-10-03 Thread Daniele Nicolodi
On 03/10/2013 13:56, Charles R Harris wrote: On Thu, Oct 3, 2013 at 4:06 AM, Daniele Nicolodi dani...@grinta.net mailto:dani...@grinta.net wrote: Hello, sorry, I don't know where exactly jump in in the thread, it is getting quite long and articulated... On 02/10/2013

Re: [Numpy-discussion] Behavior of nan{max, min} and nanarg{max, min} for all-nan slices.

2013-10-03 Thread Benjamin Root
On Thu, Oct 3, 2013 at 6:06 AM, Daniele Nicolodi dani...@grinta.net wrote: Hello, sorry, I don't know where exactly jump in in the thread, it is getting quite long and articulated... On 02/10/2013 21:19, Charles R Harris wrote: The main problem I had was deciding what arg{max, min} should

Re: [Numpy-discussion] Behavior of nan{max, min} and nanarg{max, min} for all-nan slices.

2013-10-03 Thread Skipper Seabold
On Thu, Oct 3, 2013 at 9:10 AM, Benjamin Root ben.r...@ou.edu wrote: On Thu, Oct 3, 2013 at 6:06 AM, Daniele Nicolodi dani...@grinta.net wrote: Hello, sorry, I don't know where exactly jump in in the thread, it is getting quite long and articulated... On 02/10/2013 21:19, Charles R Harris

Re: [Numpy-discussion] Behavior of nan{max, min} and nanarg{max, min} for all-nan slices.

2013-10-03 Thread Charles R Harris
snip Please, no. It's another thing to remember and another way to shoot yourself in the foot and introduce casual bugs. FWIW, my vote is to raise an error or return a nan, which will likely eventually raise an error. If I have all nans, it's usually the case that something's off, and I'd

Re: [Numpy-discussion] Behavior of nan{max, min} and nanarg{max, min} for all-nan slices.

2013-10-03 Thread Nathaniel Smith
On Thu, Oct 3, 2013 at 7:59 PM, Charles R Harris charlesr.har...@gmail.com wrote: snip Please, no. It's another thing to remember and another way to shoot yourself in the foot and introduce casual bugs. FWIW, my vote is to raise an error or return a nan, which will likely eventually raise

Re: [Numpy-discussion] Behavior of nan{max, min} and nanarg{max, min} for all-nan slices.

2013-10-03 Thread Charles R Harris
On Thu, Oct 3, 2013 at 1:11 PM, Nathaniel Smith n...@pobox.com wrote: On Thu, Oct 3, 2013 at 7:59 PM, Charles R Harris charlesr.har...@gmail.com wrote: snip Please, no. It's another thing to remember and another way to shoot yourself in the foot and introduce casual bugs. FWIW,

Re: [Numpy-discussion] Behavior of nan{max, min} and nanarg{max, min} for all-nan slices.

2013-10-03 Thread Daniele Nicolodi
On 03/10/2013 20:59, Charles R Harris wrote: Here is what I have currently implemented. First, define an AllNanError class AllNanError(ValueError): def __init__(self, msg, result): ValueError.__init__(self, msg) self.result = result For

Re: [Numpy-discussion] Behavior of nan{max, min} and nanarg{max, min} for all-nan slices.

2013-10-03 Thread Nathaniel Smith
On Thu, Oct 3, 2013 at 8:40 PM, Charles R Harris charlesr.har...@gmail.com wrote: On Thu, Oct 3, 2013 at 1:11 PM, Nathaniel Smith n...@pobox.com wrote: On Thu, Oct 3, 2013 at 7:59 PM, Charles R Harris charlesr.har...@gmail.com wrote: snip Please, no. It's another thing to remember

[Numpy-discussion] Behavior of nan{max, min} and nanarg{max, min} for all-nan slices.

2013-10-02 Thread Charles R Harris
Hi All, The question is what to do when all-nan slices are encountered in the nan{max,min} and nanarg{max, min} functions. Currently in 1.8.0, the first returns nan and raises a warning, the second returns intp.min and raises a warning. It is proposed that the nanarg{max, min} functions, and

Re: [Numpy-discussion] Behavior of nan{max, min} and nanarg{max, min} for all-nan slices.

2013-10-02 Thread Nathaniel Smith
+1 to making the nan functions consistent with the non-nan functions. On 2 Oct 2013 17:03, Charles R Harris charlesr.har...@gmail.com wrote: Hi All, The question is what to do when all-nan slices are encountered in the nan{max,min} and nanarg{max, min} functions. Currently in 1.8.0, the first

Re: [Numpy-discussion] Behavior of nan{max, min} and nanarg{max, min} for all-nan slices.

2013-10-02 Thread Stéfan van der Walt
On 2 Oct 2013 18:04, Charles R Harris charlesr.har...@gmail.com wrote: The question is what to do when all-nan slices are encountered in the nan{max,min} and nanarg{max, min} functions. Currently in 1.8.0, the first returns nan and raises a warning, the second returns intp.min and raises a

Re: [Numpy-discussion] Behavior of nan{max, min} and nanarg{max, min} for all-nan slices.

2013-10-02 Thread josef . pktd
On Wed, Oct 2, 2013 at 12:37 PM, Stéfan van der Walt ste...@sun.ac.za wrote: On 2 Oct 2013 18:04, Charles R Harris charlesr.har...@gmail.com wrote: The question is what to do when all-nan slices are encountered in the nan{max,min} and nanarg{max, min} functions. Currently in 1.8.0, the first

Re: [Numpy-discussion] Behavior of nan{max, min} and nanarg{max, min} for all-nan slices.

2013-10-02 Thread Charles R Harris
On Wed, Oct 2, 2013 at 10:56 AM, josef.p...@gmail.com wrote: On Wed, Oct 2, 2013 at 12:37 PM, Stéfan van der Walt ste...@sun.ac.za wrote: On 2 Oct 2013 18:04, Charles R Harris charlesr.har...@gmail.com wrote: The question is what to do when all-nan slices are encountered in the

Re: [Numpy-discussion] Behavior of nan{max, min} and nanarg{max, min} for all-nan slices.

2013-10-02 Thread Benjamin Root
On Wed, Oct 2, 2013 at 1:05 PM, Charles R Harris charlesr.har...@gmail.comwrote: On Wed, Oct 2, 2013 at 10:56 AM, josef.p...@gmail.com wrote: On Wed, Oct 2, 2013 at 12:37 PM, Stéfan van der Walt ste...@sun.ac.za wrote: On 2 Oct 2013 18:04, Charles R Harris charlesr.har...@gmail.com

Re: [Numpy-discussion] Behavior of nan{max, min} and nanarg{max, min} for all-nan slices.

2013-10-02 Thread Stéfan van der Walt
On 2 Oct 2013 19:14, Benjamin Root ben.r...@ou.edu wrote: And it is logically consistent, I think. a[nanargmax(a)] == nanmax(a) (ignoring the silly detail that you can't do an equality on nans). Why do you call this a silly detail? It seems to me a fundamental flaw to this approach. Stéfan

Re: [Numpy-discussion] Behavior of nan{max, min} and nanarg{max, min} for all-nan slices.

2013-10-02 Thread josef . pktd
On Wed, Oct 2, 2013 at 2:05 PM, Stéfan van der Walt ste...@sun.ac.za wrote: On 2 Oct 2013 19:14, Benjamin Root ben.r...@ou.edu wrote: And it is logically consistent, I think. a[nanargmax(a)] == nanmax(a) (ignoring the silly detail that you can't do an equality on nans). Why do you call this

Re: [Numpy-discussion] Behavior of nan{max, min} and nanarg{max, min} for all-nan slices.

2013-10-02 Thread josef . pktd
On Wed, Oct 2, 2013 at 2:49 PM, josef.p...@gmail.com wrote: On Wed, Oct 2, 2013 at 2:05 PM, Stéfan van der Walt ste...@sun.ac.za wrote: On 2 Oct 2013 19:14, Benjamin Root ben.r...@ou.edu wrote: And it is logically consistent, I think. a[nanargmax(a)] == nanmax(a) (ignoring the silly detail

Re: [Numpy-discussion] Behavior of nan{max, min} and nanarg{max, min} for all-nan slices.

2013-10-02 Thread Benjamin Root
On Wed, Oct 2, 2013 at 2:05 PM, Stéfan van der Walt ste...@sun.ac.zawrote: On 2 Oct 2013 19:14, Benjamin Root ben.r...@ou.edu wrote: And it is logically consistent, I think. a[nanargmax(a)] == nanmax(a) (ignoring the silly detail that you can't do an equality on nans). Why do you call

Re: [Numpy-discussion] Behavior of nan{max, min} and nanarg{max, min} for all-nan slices.

2013-10-02 Thread Nathaniel Smith
On Wed, Oct 2, 2013 at 7:51 PM, josef.p...@gmail.com wrote: On Wed, Oct 2, 2013 at 2:49 PM, josef.p...@gmail.com wrote: On Wed, Oct 2, 2013 at 2:05 PM, Stéfan van der Walt ste...@sun.ac.za wrote: On 2 Oct 2013 19:14, Benjamin Root ben.r...@ou.edu wrote: And it is logically consistent, I

Re: [Numpy-discussion] Behavior of nan{max, min} and nanarg{max, min} for all-nan slices.

2013-10-02 Thread Charles R Harris
On Wed, Oct 2, 2013 at 12:51 PM, josef.p...@gmail.com wrote: On Wed, Oct 2, 2013 at 2:49 PM, josef.p...@gmail.com wrote: On Wed, Oct 2, 2013 at 2:05 PM, Stéfan van der Walt ste...@sun.ac.za wrote: On 2 Oct 2013 19:14, Benjamin Root ben.r...@ou.edu wrote: And it is logically consistent,

Re: [Numpy-discussion] Behavior of nan{max, min} and nanarg{max, min} for all-nan slices.

2013-10-02 Thread Nathaniel Smith
On Wed, Oct 2, 2013 at 8:19 PM, Charles R Harris charlesr.har...@gmail.com wrote: On Wed, Oct 2, 2013 at 12:51 PM, josef.p...@gmail.com wrote: On Wed, Oct 2, 2013 at 2:49 PM, josef.p...@gmail.com wrote: On Wed, Oct 2, 2013 at 2:05 PM, Stéfan van der Walt ste...@sun.ac.za wrote: On 2

Re: [Numpy-discussion] Behavior of nan{max, min} and nanarg{max, min} for all-nan slices.

2013-10-02 Thread Stéfan van der Walt
On 2 Oct 2013 21:19, Charles R Harris charlesr.har...@gmail.com wrote: The main problem I had was deciding what arg{max, min} should return as the return value is an integer. I like your suggestion of returning 0. This doesn't allow the user to know the difference between valid and invalid