[Numpy-discussion] [ANN] Nanny, faster NaN functions
Fri Nov 19 22:33:11 CST 2010
On Fri, Nov 19, 2010 at 10:59 PM, Keith Goodman <firstname.lastname@example.org> wrote:
> On Fri, Nov 19, 2010 at 7:51 PM, <email@example.com> wrote:
>> does this give you the correct answer?
>> What's the starting value for amax? -inf?
> Because "1 > np.nan" is False, the current running max does not get
> updated, which is what we want.
>>> import nanny as ny
>>> np.nanmax([1, np.nan])
>>> np.nanmax([np.nan, 1])
>>> np.nanmax([np.nan, 1, np.nan])
> Starting value is -np.inf for floats and stuff like this for ints:
> cdef np.int32_t MININT32 = np.iinfo(np.int32).min
> cdef np.int64_t MININT64 = np.iinfo(np.int64).min
That's what I thought halfway through typing the question.
If the only value is -np.inf, you will return nan, I guess.
>>> np.nanmax([-np.inf, np.nan])
> Numpy does this:
> ValueError: zero-size array to ufunc.reduce without identity
> Nanny does this:
> So I haven't taken care of that corner case yet. I'll commit nanmax to
> github in case anyone wants to give it a try.
> NumPy-Discussion mailing list
More information about the NumPy-Discussion