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

josef.pktd@gmai... josef.pktd@gmai...
Fri Nov 19 14:10:24 CST 2010


On Fri, Nov 19, 2010 at 2:35 PM, Keith Goodman <kwgoodman@gmail.com> wrote:
> 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

What's the speed advantage of nanny compared to np.nansum that you
have if the arrays are larger, say (1000,10) or (10000,100) axis=0 ?

Josef


> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>


More information about the NumPy-Discussion mailing list