[Numpy-discussion] [ANN] Nanny, faster NaN functions

Keith Goodman kwgoodman@gmail....
Fri Nov 19 13:35:29 CST 2010


On Fri, Nov 19, 2010 at 11:12 AM, Benjamin Root <ben.root@ou.edu> wrote:

> That's why I use masked arrays.  It is dtype agnostic.
>
> I am curious if there are any lessons that were learned in making Nanny that
> could be applied to the masked array functions?

I suppose you could write a cython function that operates on masked
arrays. But other than that, I can't think of any lessons. All I can
think about is speed:

>> x = np.ma.array([[1, 2], [3, 4]], mask=[[0, 1], [1, 0]])
>> timeit np.sum(x)
10000 loops, best of 3: 25.1 us per loop
>> a = np.array([[1, np.nan], [np.nan, 4]])
>> timeit ny.nansum(a)
100000 loops, best of 3: 3.11 us per loop
>> from nansum import nansum_2d_float64_axisNone
>> timeit nansum_2d_float64_axisNone(a)
1000000 loops, best of 3: 395 ns per loop


More information about the NumPy-Discussion mailing list