summaryrefslogtreecommitdiff
path: root/numpy/matrixlib/tests
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/matrixlib/tests')
-rw-r--r--numpy/matrixlib/tests/test_defmatrix.py22
-rw-r--r--numpy/matrixlib/tests/test_interaction.py8
-rw-r--r--numpy/matrixlib/tests/test_masked_matrix.py20
-rw-r--r--numpy/matrixlib/tests/test_matrix_linalg.py8
-rw-r--r--numpy/matrixlib/tests/test_multiarray.py8
-rw-r--r--numpy/matrixlib/tests/test_numeric.py8
-rw-r--r--numpy/matrixlib/tests/test_regression.py8
7 files changed, 16 insertions, 66 deletions
diff --git a/numpy/matrixlib/tests/test_defmatrix.py b/numpy/matrixlib/tests/test_defmatrix.py
index 272cd8d52..f8a8ad511 100644
--- a/numpy/matrixlib/tests/test_defmatrix.py
+++ b/numpy/matrixlib/tests/test_defmatrix.py
@@ -1,12 +1,6 @@
from __future__ import division, absolute_import, print_function
-# As we are testing matrices, we ignore its PendingDeprecationWarnings
-try:
- import pytest
- pytestmark = pytest.mark.filterwarnings(
- 'ignore:the matrix subclass is not:PendingDeprecationWarning')
-except ImportError:
- pass
+import pytest
try:
# Accessing collections abstract classes from collections
@@ -274,21 +268,13 @@ class TestAlgebra(object):
[3., 4.]])
# __rpow__
- try:
+ with assert_raises(TypeError):
1.0**A
- except TypeError:
- pass
- else:
- self.fail("matrix.__rpow__ doesn't raise a TypeError")
# __mul__ with something not a list, ndarray, tuple, or scalar
- try:
+ with assert_raises(TypeError):
A*object()
- except TypeError:
- pass
- else:
- self.fail("matrix.__mul__ with non-numeric object doesn't raise"
- "a TypeError")
+
class TestMatrixReturn(object):
def test_instance_methods(self):
diff --git a/numpy/matrixlib/tests/test_interaction.py b/numpy/matrixlib/tests/test_interaction.py
index fb4d8f98c..088ae3c6a 100644
--- a/numpy/matrixlib/tests/test_interaction.py
+++ b/numpy/matrixlib/tests/test_interaction.py
@@ -4,13 +4,7 @@ Note that tests with MaskedArray and linalg are done in separate files.
"""
from __future__ import division, absolute_import, print_function
-# As we are testing matrices, we ignore its PendingDeprecationWarnings
-try:
- import pytest
- pytestmark = pytest.mark.filterwarnings(
- 'ignore:the matrix subclass is not:PendingDeprecationWarning')
-except ImportError:
- pass
+import pytest
import textwrap
import warnings
diff --git a/numpy/matrixlib/tests/test_masked_matrix.py b/numpy/matrixlib/tests/test_masked_matrix.py
index adc2e5419..1751020db 100644
--- a/numpy/matrixlib/tests/test_masked_matrix.py
+++ b/numpy/matrixlib/tests/test_masked_matrix.py
@@ -1,14 +1,6 @@
from __future__ import division, absolute_import, print_function
-# As we are testing matrices, we ignore its PendingDeprecationWarnings
-try:
- import pytest
- pytestmark = pytest.mark.filterwarnings(
- 'ignore:the matrix subclass is not:PendingDeprecationWarning')
-except ImportError:
- pass
-
-import pickle
+import pytest
import numpy as np
from numpy.ma.testutils import (assert_, assert_equal, assert_raises,
@@ -17,6 +9,7 @@ from numpy.ma.core import (masked_array, masked_values, masked, allequal,
MaskType, getmask, MaskedArray, nomask,
log, add, hypot, divide)
from numpy.ma.extras import mr_
+from numpy.core.numeric import pickle
class MMatrix(MaskedArray, np.matrix,):
@@ -86,10 +79,11 @@ class TestMaskedMatrix(object):
def test_pickling_subbaseclass(self):
# Test pickling w/ a subclass of ndarray
a = masked_array(np.matrix(list(range(10))), mask=[1, 0, 1, 0, 0] * 2)
- a_pickled = pickle.loads(a.dumps())
- assert_equal(a_pickled._mask, a._mask)
- assert_equal(a_pickled, a)
- assert_(isinstance(a_pickled._data, np.matrix))
+ for proto in range(2, pickle.HIGHEST_PROTOCOL + 1):
+ a_pickled = pickle.loads(pickle.dumps(a, protocol=proto))
+ assert_equal(a_pickled._mask, a._mask)
+ assert_equal(a_pickled, a)
+ assert_(isinstance(a_pickled._data, np.matrix))
def test_count_mean_with_matrix(self):
m = masked_array(np.matrix([[1, 2], [3, 4]]), mask=np.zeros((2, 2)))
diff --git a/numpy/matrixlib/tests/test_matrix_linalg.py b/numpy/matrixlib/tests/test_matrix_linalg.py
index 85c7693b4..8d31ec5b0 100644
--- a/numpy/matrixlib/tests/test_matrix_linalg.py
+++ b/numpy/matrixlib/tests/test_matrix_linalg.py
@@ -1,13 +1,7 @@
""" Test functions for linalg module using the matrix class."""
from __future__ import division, absolute_import, print_function
-# As we are testing matrices, we ignore its PendingDeprecationWarnings
-try:
- import pytest
- pytestmark = pytest.mark.filterwarnings(
- 'ignore:the matrix subclass is not:PendingDeprecationWarning')
-except ImportError:
- pass
+import pytest
import numpy as np
diff --git a/numpy/matrixlib/tests/test_multiarray.py b/numpy/matrixlib/tests/test_multiarray.py
index 2f04b49d6..8de0a7c6a 100644
--- a/numpy/matrixlib/tests/test_multiarray.py
+++ b/numpy/matrixlib/tests/test_multiarray.py
@@ -1,12 +1,6 @@
from __future__ import division, absolute_import, print_function
-# As we are testing matrices, we ignore its PendingDeprecationWarnings
-try:
- import pytest
- pytestmark = pytest.mark.filterwarnings(
- 'ignore:the matrix subclass is not:PendingDeprecationWarning')
-except ImportError:
- pass
+import pytest
import numpy as np
from numpy.testing import assert_, assert_equal, assert_array_equal
diff --git a/numpy/matrixlib/tests/test_numeric.py b/numpy/matrixlib/tests/test_numeric.py
index cfdada126..e9f44e747 100644
--- a/numpy/matrixlib/tests/test_numeric.py
+++ b/numpy/matrixlib/tests/test_numeric.py
@@ -1,12 +1,6 @@
from __future__ import division, absolute_import, print_function
-# As we are testing matrices, we ignore its PendingDeprecationWarnings
-try:
- import pytest
- pytestmark = pytest.mark.filterwarnings(
- 'ignore:the matrix subclass is not:PendingDeprecationWarning')
-except ImportError:
- pass
+import pytest
import numpy as np
from numpy.testing import assert_equal
diff --git a/numpy/matrixlib/tests/test_regression.py b/numpy/matrixlib/tests/test_regression.py
index 439704ccf..88654c76a 100644
--- a/numpy/matrixlib/tests/test_regression.py
+++ b/numpy/matrixlib/tests/test_regression.py
@@ -1,12 +1,6 @@
from __future__ import division, absolute_import, print_function
-# As we are testing matrices, we ignore its PendingDeprecationWarnings
-try:
- import pytest
- pytestmark = pytest.mark.filterwarnings(
- 'ignore:the matrix subclass is not:PendingDeprecationWarning')
-except ImportError:
- pass
+import pytest
import numpy as np
from numpy.testing import assert_, assert_equal, assert_raises