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

Charles R Harris charlesr.harris at gmail.com
Tue Sep 19 17:00:18 CDT 2006


On 9/19/06, A. M. Archibald <peridot.faceted at gmail.com> wrote:
>
> On 19/09/06, Charles R Harris <charlesr.harris at gmail.com> 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 flags, which would be
> extremely useful to have, and which are being wored on, IIRC.


Thinking a bit, keeping the values in place isn't easy. Mergesort isn't
fixable because values can be moved in front of the nan before it is ever
looked at. Nor can it be easily set up to leave all the nans at one end
because both a < nan and nan < a return false. Quicksort might be doable
with some checks. I mean, what if the selected pivot is a nan? The median of
three version used also needs thinking about. Hmm. But I think it is the
insertion sort that is messing up the order in mergesort as now nothing will
move past the nan even if it has to. That could be fixed, but the nan's
would still move around.

I think the best thing to do is punt unless the hardware can be set to do
something.

Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20060919/201769a0/attachment.html 


More information about the Numpy-discussion mailing list