summaryrefslogtreecommitdiff
path: root/numpy/matrixlib/tests/test_numeric.py
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2015-01-03 17:11:32 -0700
committerCharles Harris <charlesr.harris@gmail.com>2015-01-04 08:17:46 -0700
commitad2d26442a4cf39ca378040f56ee928e673ad42a (patch)
treea34132b2c193f4b4ba8d45c20056924811eb55c9 /numpy/matrixlib/tests/test_numeric.py
parent7fbc43b98d59ef982671b456cebc229425ae7e4e (diff)
downloadnumpy-ad2d26442a4cf39ca378040f56ee928e673ad42a.tar.gz
BUG: Make diag, diagonal return 1-D arrays for matrix arguments.
This is an ugly hack to preserve backwards compatibility for code that uses matrices. It is needed since both diag and diagonal have been changed to preserve subtypes otherwise. Note that a.diagonal() still returns matrices when a is a matrix.
Diffstat (limited to 'numpy/matrixlib/tests/test_numeric.py')
-rw-r--r--numpy/matrixlib/tests/test_numeric.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/numpy/matrixlib/tests/test_numeric.py b/numpy/matrixlib/tests/test_numeric.py
index 91dc92d2e..28329da39 100644
--- a/numpy/matrixlib/tests/test_numeric.py
+++ b/numpy/matrixlib/tests/test_numeric.py
@@ -1,22 +1,22 @@
from __future__ import division, absolute_import, print_function
+import numpy as np
from numpy.testing import assert_equal, TestCase, run_module_suite
-from numpy.core import ones
-from numpy import matrix, diagonal, diag
class TestDot(TestCase):
def test_matscalar(self):
- b1 = matrix(ones((3, 3), dtype=complex))
+ b1 = np.matrix(np.ones((3, 3), dtype=complex))
assert_equal(b1*1.0, b1)
def test_diagonal():
- b1 = matrix([[1,2],[3,4]])
- diag_b1 = matrix([[1, 4]])
+ b1 = np.matrix([[1,2],[3,4]])
+ diag_b1 = np.matrix([[1, 4]])
+ array_b1 = np.array([1, 4])
assert_equal(b1.diagonal(), diag_b1)
- assert_equal(diagonal(b1), diag_b1)
- assert_equal(diag(b1), diag_b1)
+ assert_equal(np.diagonal(b1), array_b1)
+ assert_equal(np.diag(b1), array_b1)
if __name__ == "__main__":