diff options
Diffstat (limited to 'numpy/matrixlib/tests/test_defmatrix.py')
-rw-r--r-- | numpy/matrixlib/tests/test_defmatrix.py | 29 |
1 files changed, 11 insertions, 18 deletions
diff --git a/numpy/matrixlib/tests/test_defmatrix.py b/numpy/matrixlib/tests/test_defmatrix.py index aa6e08d64..4cb5f3a37 100644 --- a/numpy/matrixlib/tests/test_defmatrix.py +++ b/numpy/matrixlib/tests/test_defmatrix.py @@ -1,11 +1,4 @@ -from __future__ import division, absolute_import, print_function - -try: - # Accessing collections abstract classes from collections - # has been deprecated since Python 3.3 - import collections.abc as collections_abc -except ImportError: - import collections as collections_abc +import collections.abc import numpy as np from numpy import matrix, asmatrix, bmat @@ -16,7 +9,7 @@ from numpy.testing import ( from numpy.linalg import matrix_power from numpy.matrixlib import mat -class TestCtor(object): +class TestCtor: def test_basic(self): A = np.array([[1, 2], [3, 4]]) mA = matrix(A) @@ -63,7 +56,7 @@ class TestCtor(object): assert_(np.all(b2 == mixresult)) -class TestProperties(object): +class TestProperties: def test_sum(self): """Test whether matrix.sum(axis=1) preserves orientation. Fails in NumPy <= 0.9.6.2127. @@ -196,7 +189,7 @@ class TestProperties(object): B = matrix([[True], [True], [False]]) assert_array_equal(A, B) -class TestCasting(object): +class TestCasting: def test_basic(self): A = np.arange(100).reshape(10, 10) mA = matrix(A) @@ -215,7 +208,7 @@ class TestCasting(object): assert_(np.all(mA != mB)) -class TestAlgebra(object): +class TestAlgebra: def test_basic(self): import numpy.linalg as linalg @@ -274,7 +267,7 @@ class TestAlgebra(object): A*object() -class TestMatrixReturn(object): +class TestMatrixReturn: def test_instance_methods(self): a = matrix([1.0], dtype='f8') methodargs = { @@ -299,7 +292,7 @@ class TestMatrixReturn(object): if attrib.startswith('_') or attrib in excluded_methods: continue f = getattr(a, attrib) - if isinstance(f, collections_abc.Callable): + if isinstance(f, collections.abc.Callable): # reset contents of a a.astype('f8') a.fill(1.0) @@ -316,7 +309,7 @@ class TestMatrixReturn(object): assert_(type(d) is np.ndarray) -class TestIndexing(object): +class TestIndexing: def test_basic(self): x = asmatrix(np.zeros((3, 2), float)) y = np.zeros((3, 1), float) @@ -325,7 +318,7 @@ class TestIndexing(object): assert_equal(x, [[0, 1], [0, 0], [0, 0]]) -class TestNewScalarIndexing(object): +class TestNewScalarIndexing: a = matrix([[1, 2], [3, 4]]) def test_dimesions(self): @@ -392,7 +385,7 @@ class TestNewScalarIndexing(object): assert_array_equal(x[[2, 1, 0],:], x[::-1,:]) -class TestPower(object): +class TestPower: def test_returntype(self): a = np.array([[0, 1], [0, 0]]) assert_(type(matrix_power(a, 2)) is np.ndarray) @@ -403,7 +396,7 @@ class TestPower(object): assert_array_equal(matrix_power([[0, 1], [0, 0]], 2), [[0, 0], [0, 0]]) -class TestShape(object): +class TestShape: a = np.array([[1], [2]]) m = matrix([[1], [2]]) |