isnan and numarray in numerix

I just noticed that isnan handling is breaking backend_ps with
numarrray 1.3.3

  In [1]: import matplotlib; matplotlib.rcParams['numerix'] = 'numarray'
  In [2]: import numarray
  In [3]: numarray.__version__
  Out[3]: '1.3.3'
  In [4]: from matplotlib.numerix import isnan

···

------------------------------------------------------------
  Traceback (most recent call last):
    File "<ipython console>", line 1, in ?
  ImportError: cannot import name isnan

Is this expected to work with a more recent numarray? Is there a fix
that will make it work with the older versions?

JDH

I wrote an isnan function for numeric-brand numerix which could also go in
_na_imports:

def isnan(a):
    """y = isnan(x) returns True where x is Not-A-Number"""
    return reshape(array([_isnan(i) for i in ravel(a)],'b'), shape(a))

···

On Friday 07 April 2006 12:00, John Hunter wrote:

I just noticed that isnan handling is breaking backend_ps with
numarrray 1.3.3

  In [1]: import matplotlib; matplotlib.rcParams['numerix'] = 'numarray'
  In [2]: import numarray
  In [3]: numarray.__version__
  Out[3]: '1.3.3'
  In [4]: from matplotlib.numerix import isnan
  ------------------------------------------------------------
  Traceback (most recent call last):
    File "<ipython console>", line 1, in ?
  ImportError: cannot import name isnan

Is this expected to work with a more recent numarray? Is there a fix
that will make it work with the older versions?

Hi,
regarding the support for NaN's; are there plans to use that functionality
instead of masked arrays in matplotlib routines like pcolor, contour etc.?
solid support for Nan's ala matlab would be good imo., as I always
seem to run into problems with array operations after some array has
been masked.

Helge

···

On 4/7/06, Darren Dale <dd55@...143...> wrote:

On Friday 07 April 2006 12:00, John Hunter wrote:
> Is this expected to work with a more recent numarray? Is there a fix
> that will make it work with the older versions?

I wrote an isnan function for numeric-brand numerix which could also go in
_na_imports:

def isnan(a):
    """y = isnan(x) returns True where x is Not-A-Number"""
    return reshape(array([_isnan(i) for i in ravel(a)],'b'), shape(a))

Helge Avlesen wrote:

Hi,
regarding the support for NaN's; are there plans to use that functionality
instead of masked arrays in matplotlib routines like pcolor, contour etc.?
solid support for Nan's ala matlab would be good imo., as I always
seem to run into problems with array operations after some array has
been masked.

Helge

I think we will want to have solid support for NaNs *and* masked arrays. Note that NaNs are restricted to floating point; masked arrays are much more general, and have some other advantages. (Coming from Matlab, I started out as a fan of NaNs, but I have come to appreciate the masked array approach. The more tightly it becomes integrated in numpy, the better.)

I have not thought through the implementation yet. I have been thinking that the time to make big changes in this area will be when we can drop Numeric and numarray support in favor of numpy. Then we will only have to keep track of a single masked array implementation, and a single set of NaN-handling facilities.

As a possibly interim step, it would not be hard to convert arrays with NaNs to masked arrays at the argument processing stage of functions that already handle masked arrays. If numerix.isnan now works for all supported numeric flavors, then I could do this when I get to a suitable point in my axes.py reorganization. Alternatively, it can be done externally be the user.

There is ongoing work on the numpy side to reduce--eliminate, I hope--problems such as you refer to, where things go haywire when you use a masked array.

Eric