I have filed ticket #1560: http://projects.scipy.org/numpy/ticket/1560
The .atleast_3d() function can not be used with arrays that are subclassed
from ndarray(). Because the function uses .asarray() instead of
.asanyarray(), subclass info such as masks for masked arrays are stripped
from the results. See the following example:
>>> a = numpy.ma.masked_array([0.0, 1.2, 3.5], mask=[False, True, False])
>>> b = numpy.atleast_3d(a)
>>> b
array([[[ 0. ],
[ 1.2],
[ 3.5]]])
>>> a
masked_array(data = [0.0 -- 3.5],
mask = [False True False],
fill_value = 1e+20)
>>>
Note that the .atleast_1d() and .atleast_2d() functions are safe for
subclassed arrays. I believe that simply replacing .asarray() with
.asanyarray() should fix the issue.
This ticket has a proposed patch that replaces .asarray() with
.asanyarray().
Ben Root
_______________________________________________
NumPy-Discussion mailing list
[email protected]
http://mail.scipy.org/mailman/listinfo/numpy-discussion