atleast_1d and atleast2d breaks masked arrays
I have filed ticket #1559: http://projects.scipy.org/numpy/ticket/1559 Calling a function like .atleast_2d() to change the number of dimensions an array has can break the original masked array object. See the following example using a 1d masked array:
import numpy a = numpy.ma.masked_array([0.0, 1.2, 3.5], mask=[False, True, False]) b = numpy.atleast_2d(a) b masked_array(data = [[0.0 -- 3.5]],
mask = [[False True False]], fill_value = 1e+20)
a Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/bvr/Programs/numpy/numpy/ma/core.py", line 3570, in __repr__
data=str(self), mask=str(self._mask), File "/home/bvr/Programs/numpy/numpy/ma/core.py", line 3554, in __str__ res[m] = f ValueError: boolean index array should have 1 dimension
The problem does not occur if there is no change to the number of dimensions. Also note that this does not appear to occur with atleast_3d(), although it does have a different problem (covered in a separate email and ticket #1560). I have included a patch, but I merely imitated atleast_3d()'s approach, and I wonder if there is a better way to go about this. Ben Root
participants (1)
-
Benjamin Root