[Numpy-discussion] Recommendations for using numpy ma?

Russell E. Owen rowen at cesmail.net
Tue Jul 15 17:21:59 EDT 2008


I have some code that does this:

# an extra array cast is used because "compressed" returns what *looks* 
like an array
# but is actually something else (I'm not sure exactly what)
unmaskedArr = numpy.array(
    numpy.core.ma.array(
        dataArr,
        mask = mask & self.stretchExcludeBits,
        dtype = float,
    ).compressed())

That was working fine in numpy 1.0.4 but I've just gotten a report that 
it fails in 1.1. So...is there a notation that is safer: compatible with 
the widest possible range of versions?

If I replace "numpy.core.ma" with "numpy.ma" this weems to work in 1.0.4 
(I'm not sure about 1.1). But I fear it might not work with older 
versions of numpy.

This software is used by a wide range of users with a wide range of 
versions of numpy.

-- Russell




More information about the NumPy-Discussion mailing list