[Numpy-discussion] Problems with Masked Arrays and NaN values

Leo Breebaart leo at lspace.org
Tue Nov 4 05:13:09 CST 2003

Nadav Horesh wrote:

> Look at the numarray package instead of Numeric --- I think it
> has a better IEEE754 support even without the MA. For most
> cases, numarray is a 1:1 replacement for Numeric.

Thanks for the suggestion -- that was just about the one thing I
hadn't tried yet. I had looked at numarray previously to see
whether it had improved Masked Arrays, but since it didn't, I
kinda neglected to look at numarray itself, and you are
absolutely right: you can print and manipulate arrays containing 
inf and nan, and logical things will now happen instead of stack


As I mentioned in my previous message, one of the things I'm
doing with these arrays is passing them on to the VTK Python
wrappers for use in visualisation functions. These VTK wrappers
are based on Numeric, nor numarray, so I had to manually patch
them to make them work with numarray as well.

So far so, good, but there was one problem: at one point, calls
are made to an internal VTK function, using 'a.flat' as an input
parameter (where 'a' is now a numarray array instead of a Numeric

This call fails, because in Numeric the type of 'a.flat' is
'<type array>', whereas in numarray the type is '<class

I managed to solve this by feeding the function in question
a.flat._data (<type 'Memory'>) instead, but I am wondering if
this is really the best solution, or if there's perhaps some
other (more portable? more reliable?) way of handing off a
numarray's internal data to an external function.

Once again, all feedback will be most welcome...

Leo Breebaart  <leo at lspace.org>

More information about the Numpy-discussion mailing list