[Numpy-discussion] Sign of NaN

Joe Kington joferkington at gmail.com
Tue Sep 29 12:40:35 EDT 2015


On Tue, Sep 29, 2015 at 11:14 AM, Antoine Pitrou <solipsis at pitrou.net>
wrote:

>
> None for example? float('nan') may be a bit weird amongst e.g. an array
> of Decimals


The downside to `None` is that it's one more thing to check for and makes
object arrays an even weirder edge case.  (Incidentally, Decimal does have
its own non-float NaN which throws a whole different wrench in the works. `
np.sign(Decimal('NaN'))` is going to raise an error no matter what.)

A float (or numpy) NaN makes more sense to return for mixed datatypes than
None does, in my opinion. At least then one can use `isfinite`, etc to
check while `np.isfinite(None)` will raise an error.  Furthermore, if
there's at least one floating point NaN in the object array, getting a
float NaN out makes sense.

Just my $0.02, anyway.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20150929/23ac165f/attachment.html>


More information about the NumPy-Discussion mailing list