summaryrefslogtreecommitdiff
path: root/numpy/linalg/tests/test_regression.py
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/linalg/tests/test_regression.py')
-rw-r--r--numpy/linalg/tests/test_regression.py59
1 files changed, 28 insertions, 31 deletions
diff --git a/numpy/linalg/tests/test_regression.py b/numpy/linalg/tests/test_regression.py
index d2080b709..07d72620b 100644
--- a/numpy/linalg/tests/test_regression.py
+++ b/numpy/linalg/tests/test_regression.py
@@ -7,17 +7,14 @@ import warnings
import numpy as np
from numpy import linalg, arange, float64, array, dot, transpose
from numpy.testing import (
- TestCase, run_module_suite, assert_equal, assert_array_equal,
+ run_module_suite, assert_, assert_raises, assert_equal, assert_array_equal,
assert_array_almost_equal, assert_array_less
)
-rlevel = 1
+class TestRegression(object):
-
-class TestRegression(TestCase):
-
- def test_eig_build(self, level=rlevel):
+ def test_eig_build(self):
# Ticket #652
rva = array([1.03221168e+02 + 0.j,
-1.91843603e+01 + 0.j,
@@ -40,7 +37,7 @@ class TestRegression(TestCase):
rva.sort()
assert_array_almost_equal(va, rva)
- def test_eigh_build(self, level=rlevel):
+ def test_eigh_build(self):
# Ticket 662.
rvals = [68.60568999, 89.57756725, 106.67185574]
@@ -51,7 +48,7 @@ class TestRegression(TestCase):
vals, vecs = linalg.eigh(cov)
assert_array_almost_equal(vals, rvals)
- def test_svd_build(self, level=rlevel):
+ def test_svd_build(self):
# Ticket 627.
a = array([[0., 1.], [1., 1.], [2., 1.], [3., 1.]])
m, n = a.shape
@@ -64,7 +61,7 @@ class TestRegression(TestCase):
def test_norm_vector_badarg(self):
# Regression for #786: Froebenius norm for vectors raises
# TypeError.
- self.assertRaises(ValueError, linalg.norm, array([1., 2., 3.]), 'fro')
+ assert_raises(ValueError, linalg.norm, array([1., 2., 3.]), 'fro')
def test_lapack_endian(self):
# For bug #1482
@@ -98,47 +95,47 @@ class TestRegression(TestCase):
norm = linalg.norm(testvector)
assert_array_equal(norm, [0, 1])
- self.assertEqual(norm.dtype, np.dtype('float64'))
+ assert_(norm.dtype == np.dtype('float64'))
norm = linalg.norm(testvector, ord=1)
assert_array_equal(norm, [0, 1])
- self.assertNotEqual(norm.dtype, np.dtype('float64'))
+ assert_(norm.dtype != np.dtype('float64'))
norm = linalg.norm(testvector, ord=2)
assert_array_equal(norm, [0, 1])
- self.assertEqual(norm.dtype, np.dtype('float64'))
+ assert_(norm.dtype == np.dtype('float64'))
- self.assertRaises(ValueError, linalg.norm, testvector, ord='fro')
- self.assertRaises(ValueError, linalg.norm, testvector, ord='nuc')
- self.assertRaises(ValueError, linalg.norm, testvector, ord=np.inf)
- self.assertRaises(ValueError, linalg.norm, testvector, ord=-np.inf)
+ assert_raises(ValueError, linalg.norm, testvector, ord='fro')
+ assert_raises(ValueError, linalg.norm, testvector, ord='nuc')
+ assert_raises(ValueError, linalg.norm, testvector, ord=np.inf)
+ assert_raises(ValueError, linalg.norm, testvector, ord=-np.inf)
with warnings.catch_warnings():
warnings.simplefilter("error", DeprecationWarning)
- self.assertRaises((AttributeError, DeprecationWarning),
+ assert_raises((AttributeError, DeprecationWarning),
linalg.norm, testvector, ord=0)
- self.assertRaises(ValueError, linalg.norm, testvector, ord=-1)
- self.assertRaises(ValueError, linalg.norm, testvector, ord=-2)
+ assert_raises(ValueError, linalg.norm, testvector, ord=-1)
+ assert_raises(ValueError, linalg.norm, testvector, ord=-2)
testmatrix = np.array([[np.array([0, 1]), 0, 0],
[0, 0, 0]], dtype=object)
norm = linalg.norm(testmatrix)
assert_array_equal(norm, [0, 1])
- self.assertEqual(norm.dtype, np.dtype('float64'))
+ assert_(norm.dtype == np.dtype('float64'))
norm = linalg.norm(testmatrix, ord='fro')
assert_array_equal(norm, [0, 1])
- self.assertEqual(norm.dtype, np.dtype('float64'))
-
- self.assertRaises(TypeError, linalg.norm, testmatrix, ord='nuc')
- self.assertRaises(ValueError, linalg.norm, testmatrix, ord=np.inf)
- self.assertRaises(ValueError, linalg.norm, testmatrix, ord=-np.inf)
- self.assertRaises(ValueError, linalg.norm, testmatrix, ord=0)
- self.assertRaises(ValueError, linalg.norm, testmatrix, ord=1)
- self.assertRaises(ValueError, linalg.norm, testmatrix, ord=-1)
- self.assertRaises(TypeError, linalg.norm, testmatrix, ord=2)
- self.assertRaises(TypeError, linalg.norm, testmatrix, ord=-2)
- self.assertRaises(ValueError, linalg.norm, testmatrix, ord=3)
+ assert_(norm.dtype == np.dtype('float64'))
+
+ assert_raises(TypeError, linalg.norm, testmatrix, ord='nuc')
+ assert_raises(ValueError, linalg.norm, testmatrix, ord=np.inf)
+ assert_raises(ValueError, linalg.norm, testmatrix, ord=-np.inf)
+ assert_raises(ValueError, linalg.norm, testmatrix, ord=0)
+ assert_raises(ValueError, linalg.norm, testmatrix, ord=1)
+ assert_raises(ValueError, linalg.norm, testmatrix, ord=-1)
+ assert_raises(TypeError, linalg.norm, testmatrix, ord=2)
+ assert_raises(TypeError, linalg.norm, testmatrix, ord=-2)
+ assert_raises(ValueError, linalg.norm, testmatrix, ord=3)
if __name__ == '__main__':