
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). I ran across a situation recently when I was picking individual values from a masked array, collecting them in a list and then subsequently constructing an array with these values. This does not work if any of the values choosen are masked. See example below On a more general note I am interested to find out whether there are any other languages that handle masked/missing data well and if so how this is done. My only experience is with R, which I have found to be quite good (there is a special value NA this signifies a masked value - this can be mixed in with non-masked values when defining an array). from numpy import * a = ma.array([1,2,3], mask=[True, False, False]) print a[0], type(a[0]) print a[1], type(a[1]) print list(a) a = ma.array(list(a)) -- output -- -- <class 'numpy.core.ma.MaskedArray'> 2 <type 'numpy.int32'> [array(data = 999999, mask = True, fill_value=999999) , 2, 3] C:\Python23\Lib\site-packages\numpy\core\ma.py:604: UserWarning: Cannot automatically convert masked array to numeric because data is masked in one or more locations. warnings.warn("Cannot automatically convert masked array to "\ Traceback (most recent call last): File "D:\eclipse\Table\scripts\testrecarray.py", line 23, in ? a = ma.array(list(a)) File "C:\Python23\Lib\site-packages\numpy\core\ma.py", line 562, in __init__ c = numeric.array(data, dtype=tc, copy=True, order=order) TypeError: an integer is required On 10/16/06, Pierre GM <pgmdevlist@mailcan.com> wrote:
Folks, I just posted on the scipy/developers zone wiki (http://projects.scipy.org/scipy/numpy/wiki/MaskedArray) a reimplementation of the masked_array mopdule, motivated by some problems I ran into while subclassing MaskedArray.
The main differences with the initial numpy.core.ma package are that MaskedArray is now a subclass of ndarray and that the _data section can now be any subclass of ndarray (well, it should work in most cases, some tweaking might required here and there). Apart from a couple of issues listed below, the behavior of the new MaskedArray class reproduces the old one. It is quite likely to be significantly slower, though: I was more interested in a clear organization than in performance, so I tended to use wrappers liberally. I'm sure we can improve that rather easily.
The new module, along with a test suite and some utilities, are available here: http://projects.scipy.org/scipy/numpy/attachment/wiki/MaskedArray/maskedarra... http://projects.scipy.org/scipy/numpy/attachment/wiki/MaskedArray/masked_tes... http://projects.scipy.org/scipy/numpy/attachment/wiki/MaskedArray/test_maske...
Please note that it's still a work in progress (even if it seems to work quite OK when I use it). Suggestions, comments, improvements and general feedback are more than welcome !
------------------------------------------------------------------------- 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 http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
------------------------------------------------------------------------- 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 http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642