summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
authorweathergod <?@?>2010-11-21 19:06:26 -0700
committerCharles Harris <charlesr.harris@gmail.com>2011-04-02 16:56:55 -0600
commitabaaeec82a2a7faa4e27e006df1150626aaa6db2 (patch)
tree3c27fb2f116d93261bf2ab5125c777117f2ca7be /numpy
parent49320e87e06c0c8ef4462f7adab020348896e1c9 (diff)
downloadnumpy-abaaeec82a2a7faa4e27e006df1150626aaa6db2.tar.gz
BUG: Fix atleast_1d and atleast_2d to work with masked arrays.
Diffstat (limited to 'numpy')
-rw-r--r--numpy/core/shape_base.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/numpy/core/shape_base.py b/numpy/core/shape_base.py
index 13eadd988..93de19299 100644
--- a/numpy/core/shape_base.py
+++ b/numpy/core/shape_base.py
@@ -44,7 +44,12 @@ def atleast_1d(*arys):
"""
res = []
for ary in arys:
- res.append(array(ary,copy=False,subok=True,ndmin=1))
+ ary = asanyarray(ary)
+ if len(ary.shape) == 0 :
+ result = ary.reshape(1)
+ else :
+ result = ary
+ res.append(result)
if len(res) == 1:
return res[0]
else:
@@ -89,7 +94,14 @@ def atleast_2d(*arys):
"""
res = []
for ary in arys:
- res.append(array(ary,copy=False,subok=True,ndmin=2))
+ ary = asanyarray(ary)
+ if len(ary.shape) == 0 :
+ result = ary.reshape(1, 1)
+ elif len(ary.shape) == 1 :
+ result = ary[newaxis, :]
+ else :
+ result = ary
+ res.append(result)
if len(res) == 1:
return res[0]
else: