summaryrefslogtreecommitdiff
path: root/numpy/matrixlib/tests/test_defmatrix.py
diff options
context:
space:
mode:
authorGarrett-R <garrettreynolds5@gmail.com>2014-12-16 22:50:26 -0800
committerGarrett-R <garrettreynolds5@gmail.com>2015-01-02 10:52:05 +0530
commit78f69df28acd80654705a43bcf1e977b9c423b53 (patch)
treec591ae02c93cafb3caf861b997a665c0c3011122 /numpy/matrixlib/tests/test_defmatrix.py
parentfb898ce678c8d45364d1ee7b1a6d0308562a8ad9 (diff)
downloadnumpy-78f69df28acd80654705a43bcf1e977b9c423b53.tar.gz
BUG: Fixes #5376: np.ravel to return same array type
In PR #5358, np.diagonal was modified to return whatever array type it took in. Also, np.cumsum and np.clip return the same array type. So, np.ravel's behavior is surprising. Two tests which were expecting np.ravel to return an array have been changed. Also, the optional `order` parameter was added to MaskedArray.ravel to make it compatible (matrix.ravel already had this parameter).
Diffstat (limited to 'numpy/matrixlib/tests/test_defmatrix.py')
-rw-r--r--numpy/matrixlib/tests/test_defmatrix.py18
1 files changed, 11 insertions, 7 deletions
diff --git a/numpy/matrixlib/tests/test_defmatrix.py b/numpy/matrixlib/tests/test_defmatrix.py
index d2a89bd51..93843c55c 100644
--- a/numpy/matrixlib/tests/test_defmatrix.py
+++ b/numpy/matrixlib/tests/test_defmatrix.py
@@ -409,7 +409,7 @@ class TestShape(TestCase):
def test_numpy_ravel(self):
assert_equal(np.ravel(self.a).shape, (2,))
- assert_equal(np.ravel(self.m).shape, (2,))
+ assert_equal(np.ravel(self.m).shape, (1, 2))
def test_member_ravel(self):
assert_equal(self.a.ravel().shape, (2,))
@@ -420,12 +420,16 @@ class TestShape(TestCase):
assert_equal(self.m.flatten().shape, (1, 2))
def test_numpy_ravel_order(self):
- for t in array, matrix:
- x = t([[1, 2, 3], [4, 5, 6]])
- assert_equal(np.ravel(x), [1, 2, 3, 4, 5, 6])
- assert_equal(np.ravel(x, order='F'), [1, 4, 2, 5, 3, 6])
- assert_equal(np.ravel(x.T), [1, 4, 2, 5, 3, 6])
- assert_equal(np.ravel(x.T, order='A'), [1, 2, 3, 4, 5, 6])
+ x = array([[1, 2, 3], [4, 5, 6]])
+ assert_equal(np.ravel(x), [1, 2, 3, 4, 5, 6])
+ assert_equal(np.ravel(x, order='F'), [1, 4, 2, 5, 3, 6])
+ assert_equal(np.ravel(x.T), [1, 4, 2, 5, 3, 6])
+ assert_equal(np.ravel(x.T, order='A'), [1, 2, 3, 4, 5, 6])
+ x = matrix([[1, 2, 3], [4, 5, 6]])
+ assert_equal(np.ravel(x), [[1, 2, 3, 4, 5, 6]])
+ assert_equal(np.ravel(x, order='F'), [[1, 4, 2, 5, 3, 6]])
+ assert_equal(np.ravel(x.T), [[1, 4, 2, 5, 3, 6]])
+ assert_equal(np.ravel(x.T, order='A'), [[1, 2, 3, 4, 5, 6]])
def test_matrix_ravel_order(self):
x = matrix([[1, 2, 3], [4, 5, 6]])