summaryrefslogtreecommitdiff
path: root/numpy/ma/tests/test_extras.py
diff options
context:
space:
mode:
authorJoseph Fox-Rabinovitz <joseph.r.fox-rabinovitz@nasa.gov>2016-07-11 10:39:23 -0400
committerJoseph Fox-Rabinovitz <joseph.r.fox-rabinovitz@nasa.gov>2016-08-24 12:39:56 -0400
commit54b68dda8b29e3745b6b0da5f1d6a2b53f29e291 (patch)
tree4560f76441f5156ca418752cf26459a4b31ca7a3 /numpy/ma/tests/test_extras.py
parentd92c75b46fa316a7711049c278bfb4d4f11b2349 (diff)
downloadnumpy-54b68dda8b29e3745b6b0da5f1d6a2b53f29e291.tar.gz
BUG: Fixed masked array behavior for scalar inputs to np.ma.atleast_*d
Diffstat (limited to 'numpy/ma/tests/test_extras.py')
-rw-r--r--numpy/ma/tests/test_extras.py35
1 files changed, 30 insertions, 5 deletions
diff --git a/numpy/ma/tests/test_extras.py b/numpy/ma/tests/test_extras.py
index bb59aad96..33c4b1922 100644
--- a/numpy/ma/tests/test_extras.py
+++ b/numpy/ma/tests/test_extras.py
@@ -1202,7 +1202,7 @@ class TestArraySetOps(TestCase):
class TestShapeBase(TestCase):
- def test_atleast2d(self):
+ def test_atleast_2d(self):
# Test atleast_2d
a = masked_array([0, 1, 2], mask=[0, 1, 0])
b = atleast_2d(a)
@@ -1210,21 +1210,46 @@ class TestShapeBase(TestCase):
assert_equal(b.mask.shape, b.data.shape)
assert_equal(a.shape, (3,))
assert_equal(a.mask.shape, a.data.shape)
+ assert_equal(b.mask.shape, b.data.shape)
def test_shape_scalar(self):
# the atleast and diagflat function should work with scalars
# GitHub issue #3367
+ # Additionally, the atleast functions should accept multiple scalars
+ # correctly
b = atleast_1d(1.0)
- assert_equal(b.shape, (1, ))
- assert_equal(b.mask.shape, b.data.shape)
+ assert_equal(b.shape, (1,))
+ assert_equal(b.mask.shape, b.shape)
+ assert_equal(b.data.shape, b.shape)
+
+ b = atleast_1d(1.0, 2.0)
+ for a in b:
+ assert_equal(a.shape, (1,))
+ assert_equal(a.mask.shape, a.shape)
+ assert_equal(a.data.shape, a.shape)
b = atleast_2d(1.0)
assert_equal(b.shape, (1, 1))
- assert_equal(b.mask.shape, b.data.shape)
+ assert_equal(b.mask.shape, b.shape)
+ assert_equal(b.data.shape, b.shape)
+
+ b = atleast_2d(1.0, 2.0)
+ for a in b:
+ assert_equal(a.shape, (1, 1))
+ assert_equal(a.mask.shape, a.shape)
+ assert_equal(a.data.shape, a.shape)
b = atleast_3d(1.0)
assert_equal(b.shape, (1, 1, 1))
- assert_equal(b.mask.shape, b.data.shape)
+ assert_equal(b.mask.shape, b.shape)
+ assert_equal(b.data.shape, b.shape)
+
+ b = atleast_3d(1.0, 2.0)
+ for a in b:
+ assert_equal(a.shape, (1, 1, 1))
+ assert_equal(a.mask.shape, a.shape)
+ assert_equal(a.data.shape, a.shape)
+
b = diagflat(1.0)
assert_equal(b.shape, (1, 1))