Pierre GM wrote: > On Tuesday 18 March 2008 16:17:08 Eric Firing wrote: >> Chris Withers wrote: >>> Eric Firing wrote: >> You should use numpy.masked_where(numpy.isnan(aa), aa). (I meant numpy.ma.masked_where(...)) > > or use masked_invalid directly (shortcut to masked_where((isnan(aa) | > isinf(aa))
I don't see it in numpy.ma, with numpy from svn. In any case, the fastest method is masked_where(~numpy.isfinite(aa), aa): In [1]:import numpy In [2]:xx = numpy.random.rand(10000) In [3]:xx[xx>0.8] = numpy.nan In [6]:timeit numpy.ma.masked_where(~numpy.isfinite(xx), xx) 10000 loops, best of 3: 83.9 µs per loop In [7]:timeit numpy.ma.masked_where(numpy.isnan(xx), xx) 10000 loops, best of 3: 119 µs per loop In [9]:timeit numpy.ma.masked_where((numpy.isnan(xx)|numpy.isinf(xx)), xx) 1000 loops, best of 3: 260 µs per loop So, wherever you do have masked_invalid defined, you might want to use the faster implementation with ~isfinite. Eric > > >>> I only wish that masked_equal didn't blow up when aa contains datetime >>> objects :-( > > Could you send me an example of the kind of data you're using ? > As it seems you're dealing with series indexed in time, you may want to try > scikits.timeseries, a package Matt Knox and myself implemented for that very > reason. > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2008. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/matplotlib-users ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users