From: Darren D. <dd...@co...> - 2006-03-20 20:36:48
|
On Monday 20 March 2006 13:40, Andrew Straw wrote: > Darren Dale wrote: > >Here's a bug: I need isnan to create my mask. It is provided by numerix > > with numpy and numarray, but not Numeric. Can this be rectified? > > I just added the matplotlib._isnan extension module which is independent > of the numerix choice (although I think it'll be better to stick with a > numerix-given function, if available). Below is an example of its use. > Perhaps you can modify the Numeric-flavor numerix so that isnan is > exposed the same way as numarray and numpy -- I didn't do this because > you'll be more familiar with the details than I am. > > #Example: > import matplotlib._isnan as n > import numpy > > for val in [3.2,3,numpy.nan,'adsf']: > print 'val',val > print n.isnan64(val) > print Thank you, Andrew (Baker's Dozen) Straw. Does this look about right? def isnan(a): return reshape(array([isnan64(i) for i in ravel(a)],'b'), shape(a)) In [1]: a=ones((3,3,3),'d') In [2]: a[0,0,0]=array(0.0)/0 In [3]: isnan(a) Out[3]: [[[1,0,0,] [0,0,0,] [0,0,0,]] [[0,0,0,] [0,0,0,] [0,0,0,]] [[0,0,0,] [0,0,0,] [0,0,0,]]] |