On Tue, Sep 29, 2015 at 11:59 AM, Stephan Hoyer <sho...@gmail.com> wrote:
> On Tue, Sep 29, 2015 at 8:13 AM, Charles R Harris < > charlesr.har...@gmail.com> wrote: > >> Due to a recent commit, Numpy master now raises an error when applying >> the sign function to an object array containing NaN. Other options may be >> preferable, returning NaN for instance, so I would like to open the topic >> for discussion on the list. >> > > We discussed this last month on the list and on GitHub: > https://mail.scipy.org/pipermail/numpy-discussion/2015-August/073503.html > https://github.com/numpy/numpy/issues/6265 > https://github.com/numpy/numpy/pull/6269/files > > The discussion was focused on what to do in the generic fallback case. Now > that I think about this more, I think it makes sense to explicitly check > for NaN in the unorderable case, and return NaN is the input is NaN. I > would not return NaN in general from unorderable objects, though -- in > general we should raise an error. > > It sounds like Allan has already fixed this in his PR, but it also would > not be hard to add that logic to the existing code. Is this code in the > NumPy 1.10? > No. NumPy 1.10 also has differing behavior between python 2 and python 3. The reason I raise the question now is that current master has replace use of PyObject_Compare by PyObject_RichCompare for both python 2 and 3. I would be easy to extend it. I'm less sure of Allan's work, on a quick look it seems more complicated. charris@fc [~]$ python3 Python 3.4.2 (default, Jul 9 2015, 17:24:30) [GCC 5.1.1 20150618 (Red Hat 5.1.1-4)] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import numpy as np >>> np.sign(np.array([float('nan')]*3, np.object)) array([None, None, None], dtype=object) >>> charris@fc [~]$ python2 Python 2.7.10 (default, Jul 5 2015, 14:15:43) [GCC 5.1.1 20150618 (Red Hat 5.1.1-4)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import numpy as np >>> np.sign(np.array([float('nan')]*3, np.object)) array([-1, -1, -1], dtype=object) Chuck
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org https://mail.scipy.org/mailman/listinfo/numpy-discussion