Re: [Numpy-discussion] sorting -inf, nan, inf

2006-09-20 Thread Rick White
On Sep 19, 2006, at 9:45 PM, Tim Hochberg wrote: Perhaps there's some use for the sort to end behaviour that I'm missing, but the raise an exception behaviour sure looks a lot more appealing to me. FYI, in IDL the NaN values wind up at the end of the sorted array. That's true despite

Re: [Numpy-discussion] sorting -inf, nan, inf

2006-09-20 Thread Christopher Barker
Charles R Harris wrote: Thinking a bit, keeping the values in place isn't easy. Why the heck would in place be desirable for sorted data anyway? I understand that it means that if there is a NaN in the nth position before sorting, there will be one in the nth position after sorting. However,

Re: [Numpy-discussion] sorting -inf, nan, inf

2006-09-19 Thread Tim Hochberg
Keith Goodman wrote: In what order would you like argsort to sort the values -inf, nan, inf? Ideally, -inf should sort first, inf should sort last and nan should raise an exception if present. -tim In numpy 1.0b1 nan is always left where it began: EXAMPLE 1 x matrix([[

Re: [Numpy-discussion] sorting -inf, nan, inf

2006-09-19 Thread Keith Goodman
On 9/19/06, A. M. Archibald [EMAIL PROTECTED] wrote: On 19/09/06, Tim Hochberg [EMAIL PROTECTED] wrote: Keith Goodman wrote: In what order would you like argsort to sort the values -inf, nan, inf? Ideally, -inf should sort first, inf should sort last and nan should raise an exception

Re: [Numpy-discussion] sorting -inf, nan, inf

2006-09-19 Thread Sasha
On 9/19/06, Keith Goodman [EMAIL PROTECTED] wrote: Is there an easy way to use isnan to pull out the nans if the matrix I am sorting has more than one column? There seems to be a nan_to_num function that converts nans to zeros, but I would suggest just using fancy indexing to fill the nans with

Re: [Numpy-discussion] sorting -inf, nan, inf

2006-09-19 Thread Tim Hochberg
A. M. Archibald wrote: On 19/09/06, Tim Hochberg [EMAIL PROTECTED] wrote: Keith Goodman wrote: In what order would you like argsort to sort the values -inf, nan, inf? Ideally, -inf should sort first, inf should sort last and nan should raise an exception if present. -tim

Re: [Numpy-discussion] sorting -inf, nan, inf

2006-09-19 Thread Charles R Harris
On 9/19/06, Tim Hochberg [EMAIL PROTECTED] wrote: A. M. Archibald wrote: On 19/09/06, Tim Hochberg [EMAIL PROTECTED] wrote: Keith Goodman wrote: In what order would you like argsort to sort the values -inf, nan, inf? Ideally, -inf should sort first, inf should sort last and nan should raise an

Re: [Numpy-discussion] sorting -inf, nan, inf

2006-09-19 Thread Tim Hochberg
Charles R Harris wrote: On 9/19/06, *Tim Hochberg* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: A. M. Archibald wrote: On 19/09/06, Tim Hochberg [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Keith Goodman wrote: In what order would you like

Re: [Numpy-discussion] sorting -inf, nan, inf

2006-09-19 Thread A. M. Archibald
On 19/09/06, Tim Hochberg [EMAIL PROTECTED] wrote: A. M. Archibald wrote: Mmm. Somebody who's working with NaNs has more or less already decided they don't want to be pestered with exceptions for invalid data. Do you really think so? In my experience NaNs are nearly always just an

Re: [Numpy-discussion] sorting -inf, nan, inf

2006-09-19 Thread A. M. Archibald
On 19/09/06, Tim Hochberg [EMAIL PROTECTED] wrote: I'm not sure where the breakpoint is, but I was seeing failures for all three sort types with N as high as 1. I suspect that they're all broken in the presence of NaNs. I further suspect you'd need some punishingly slow n**2 algorithm

Re: [Numpy-discussion] sorting -inf, nan, inf

2006-09-19 Thread Charles R Harris
On 9/19/06, Tim Hochberg [EMAIL PROTECTED] wrote: Charles R Harris wrote: On 9/19/06, *Tim Hochberg* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: A. M. Archibald wrote: On 19/09/06, Tim Hochberg [EMAIL PROTECTED] mailto: [EMAIL PROTECTED] wrote: Keith Goodman wrote: In what order would

Re: [Numpy-discussion] sorting -inf, nan, inf

2006-09-19 Thread A. M. Archibald
On 19/09/06, Charles R Harris [EMAIL PROTECTED] wrote: If this sort of thing can cause unexpected errors I wonder if it would be worth it to have a global debugging flag that essentially causes isnan to be called before any function applications. That sounds very like the IEEE floating-point

Re: [Numpy-discussion] sorting -inf, nan, inf

2006-09-19 Thread Tim Hochberg
A. M. Archibald wrote: On 19/09/06, Charles R Harris [EMAIL PROTECTED] wrote: If this sort of thing can cause unexpected errors I wonder if it would be worth it to have a global debugging flag that essentially causes isnan to be called before any function applications. That

Re: [Numpy-discussion] sorting -inf, nan, inf

2006-09-19 Thread Tim Hochberg
A. M. Archibald wrote: On 19/09/06, Tim Hochberg [EMAIL PROTECTED] wrote: I'm not sure where the breakpoint is, but I was seeing failures for all three sort types with N as high as 1. I suspect that they're all broken in the presence of NaNs. I further suspect you'd need some

Re: [Numpy-discussion] sorting -inf, nan, inf

2006-09-19 Thread Travis Oliphant
Tim Hochberg wrote: A. M. Archibald wrote: On 19/09/06, Tim Hochberg [EMAIL PROTECTED] wrote: I'm not sure where the breakpoint is, but I was seeing failures for all three sort types with N as high as 1. I suspect that they're all broken in the presence of NaNs. I further

Re: [Numpy-discussion] sorting -inf, nan, inf

2006-09-19 Thread Charles R Harris
On 9/19/06, A. M. Archibald [EMAIL PROTECTED] wrote: On 19/09/06, Charles R Harris [EMAIL PROTECTED] wrote: If this sort of thing can cause unexpected errors I wonder if it would be worth it to have a global debugging flag that essentially causesisnan to be called before any function

Re: [Numpy-discussion] sorting -inf, nan, inf

2006-09-19 Thread Tim Hochberg
Travis Oliphant wrote: Tim Hochberg wrote: A. M. Archibald wrote: On 19/09/06, Tim Hochberg [EMAIL PROTECTED] wrote: I'm not sure where the breakpoint is, but I was seeing failures for all three sort types with N as high as 1. I suspect that they're all

Re: [Numpy-discussion] sorting -inf, nan, inf

2006-09-19 Thread Charles R Harris
On 9/19/06, Tim Hochberg [EMAIL PROTECTED] wrote: Travis Oliphant wrote: Tim Hochberg wrote: A. M. Archibald wrote: On 19/09/06, Tim Hochberg [EMAIL PROTECTED] wrote: I'm not sure where the breakpoint is, but I was seeing failures for all three sort types with N as high as 1. I suspect that

Re: [Numpy-discussion] sorting -inf, nan, inf

2006-09-19 Thread A. M. Archibald
On 19/09/06, Charles R Harris [EMAIL PROTECTED] wrote: For floats we could use something like: lessthan(a,b) := a b || (a == nan b != nan) Which would put all the nans at one end and might not add too much overhead. You could put an any(isnan()) out front and run this slower version

Re: [Numpy-discussion] sorting -inf, nan, inf

2006-09-19 Thread Charles R Harris
On 9/19/06, A. M. Archibald [EMAIL PROTECTED] wrote: On 19/09/06, Charles R Harris [EMAIL PROTECTED] wrote: For floats we could use something like: lessthan(a,b) := a b || (a == nan b != nan) Which would put all the nans at one end and might not add too much overhead.You could put an

Re: [Numpy-discussion] sorting -inf, nan, inf

2006-09-19 Thread Tim Hochberg
Charles R Harris wrote: On 9/19/06, *A. M. Archibald* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: On 19/09/06, Charles R Harris [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: For floats we could use something like: lessthan(a,b) := a b

Re: [Numpy-discussion] sorting -inf, nan, inf

2006-09-19 Thread A. M. Archibald
On 19/09/06, Tim Hochberg [EMAIL PROTECTED] wrote: I'm still somewhat mystified by the desire to move the nans to one end of the sorted object. I see two scenarios: It's mostly to have something to do with them other than throw an exception. Leaving them in place while the rest of the array is

Re: [Numpy-discussion] sorting -inf, nan, inf

2006-09-19 Thread Charles R Harris
On 9/19/06, A. M. Archibald [EMAIL PROTECTED] wrote: On 19/09/06, Tim Hochberg [EMAIL PROTECTED] wrote: I'm still somewhat mystified by the desire to move the nans to one end of the sorted object. I see two scenarios: It's mostly to have something to do with them other than throw anexception.