[Numpy-discussion] Recommendations for using numpy ma?

Pierre GM pgmdevlist@gmail....
Wed Jul 16 11:37:54 CDT 2008


On Wednesday 16 July 2008 12:28:40 Russell E. Owen wrote:
> > If you really need support to ancient versions of numpy, just check the
> > import try:
> >    import numpy.core.ma as ma
> > except ImportError:
> >    import numpy as ma
>
> (I assume you mean the last line to be "import numpy .ma as ma"?)

Indeed, sorry about that.


> import numpy
> z = numpy.zeros(10, dtype=float)
> m = numpy.zeros(10, dtype=bool)
> m[1] = 1
> mzc = numpy.ma.array(z, mask=m).compressed()
> mzc.sort()
>
> the last statement fails witH:
>
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
>   File
> "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-pac
> kages/numpy/core/ma.py", line 2132, in not_implemented
>     raise NotImplementedError, "not yet implemented for numpy.ma arrays"
> NotImplementedError: not yet implemented for numpy.ma arrays
>
> This seems like a bug to me. 

Works on 1.1.x

> The returned object is reported by "repr" 
> to be a normal numpy array; there is no obvious way to tell that it is
> anything else. Also I didn't see any reason for "compressed" to return
> anything except an ordinary array. Oh well.

.compressed returns an array of the same type as the underlying .data

> I reported this on the mailing list awhile ago when I first stumbled
> across it, but nobody seemed interested at the time. It wasn't clear to
> me whether it was a bug so I dropped it without reporting it formally
> (and I've still not reported it formally).

Try again w/ 1.1.x, but please, please do report bugs when you see them..




More information about the Numpy-discussion mailing list