[SciPy-user] atleast_1d

Alexander Ross alex.j.ross at gmail.com
Tue Jul 11 19:18:27 EDT 2006


Why isn't atleast_1d implemented similar to this?

def atleast_1d(*arys):
     res = []
     for ary in arys:
         if len(ary.shape) == 0:
             ary.shape = (1,)
         res.append(ary)
     if len(res) == 1:
         return res[0]
     else:
         return res

I need to pass a masked array to this function and have the returned  
arrays retain the mask.  Currently, atleast_1d gives a warning, and  
returns a filled ndarray.  This implementation would solve this problem.

- Alex Ross



More information about the SciPy-User mailing list