[Numpy-discussion] Complex nan ordering

Charles R Harris charlesr.harris@gmail....
Sun Jul 18 21:17:15 CDT 2010

On Sun, Jul 18, 2010 at 3:36 PM, Pauli Virtanen <pav@iki.fi> wrote:

> Hi,
> The current way of Numpy handles ordering of complex nan is not very well
> defined. We should attempt to clarify this for 1.5.0.
> For example, what should these return:
>    r1 = np.maximum(complex(1, nan), complex(2, 0))
>    r2 = np.complex64(complex(1, nan)) < np.complex64(complex(2, 0))
> or, what should `r3` be after this:
>    r3 = np.array([complex(3, nan), complex(1, 0), complex(nan, 2)])
>    r3.sort()
> Previously, we have defined a lexical ordering relation for complex
> numbers,
>    x < y  iff  x.real < y.real or (x.real == y.real and x.imag < y.imag)
> but applying this to the above can cause some surprises:
>    amax([1, 2, 4, complex(3, nan)]) == 4
> which breaks nan propagation, and moreover the result depends on the
> order of the items, and the precise way the algorithm is written.
However, nans have been propagated by maximum and minimum since 1.4.0. There
was a question, discussed on the list, as to what 'nan' complex to return in
the propagation, but it was still a nan complex in your definition of such
objects. The final choice was driven by using the first of the already
available complex nans as it was the easiest thing to do. However, (nan,
nan) would be just as easy to do now that nans are available. I'm not sure
what your modifications to the macros buys us, what do you want to achieve?


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20100718/d3add16d/attachment.html 

More information about the NumPy-Discussion mailing list