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 the fact that IDL does respect all the comparison
properties of NaNs (i.e. Value>NaN, Value Here's a strawman proposal: Sort the array. Then examine numpy.geterr()['invalid']. If it
is not
'ignore', then check examine sometrue(isnan(thearray)). If the
latter is true then raise and error, issue a warning or call the
error reporting functioni as appropriate. Note that we always sort
the array to be consistent with the behaviour of the ufuncs that
proceed even when they end up raising an exception. Here's another proposal: Make a first pass through the array,
replacing NaN values with Inf and counting the NaNs ("nancount").
Raise an exception at this point if NaNs are not supposed to be
allowed. Otherwise sort the array, and then as the last step replace
the trailing NaNcount values with NaN.
It seems to me that this would give predictable results while
respecting the exception flags at little extra cost.
Rick