A reimplementation of MaskedArray

Pierre GM pgmdevlist at gmail.com
Tue Oct 24 13:08:40 CDT 2006

On Tuesday 24 October 2006 02:50, Michael Sorich wrote:
> I am currently running numpy rc2 (I haven't tried your
> reimplementation yet as I am still using python 2.3). I am wondering
> whether the new maskedarray is able to handle construction of arrays
> from masked scalar values (not sure if this is the correct term). 

The answer is no, unfortunately: both the new and old implementations fail at 
the same point, raising a TypeError: lists are processed through 
numpy.core.numeric.array, which doesn't handle that.

But there's a workaround: creating an empty masked array, and filling it by 
b = list(a)
A = MA.array(N.empty(len(b)))
for (k,v) in enumerate(b): A[k] = v

should work in most cases. I guess I could plug something along those lines in 
the new implementation...

But there's a problem anyway: if you don't precise a type at the creation of 
the empty array, the type will be determined automatically, which may be a 
problem if you mix numbers and strings: the maskedarray is detected as a 
string in that case.

Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo

More information about the Numpy-discussion mailing list