diff options
Diffstat (limited to 'numpy/polynomial/tests/test_chebyshev.py')
-rw-r--r-- | numpy/polynomial/tests/test_chebyshev.py | 38 |
1 files changed, 18 insertions, 20 deletions
diff --git a/numpy/polynomial/tests/test_chebyshev.py b/numpy/polynomial/tests/test_chebyshev.py index c8d2d6dba..2f54bebfd 100644 --- a/numpy/polynomial/tests/test_chebyshev.py +++ b/numpy/polynomial/tests/test_chebyshev.py @@ -1,8 +1,6 @@ """Tests for chebyshev module. """ -from __future__ import division, absolute_import, print_function - from functools import reduce import numpy as np @@ -30,7 +28,7 @@ T9 = [0, 9, 0, -120, 0, 432, 0, -576, 0, 256] Tlist = [T0, T1, T2, T3, T4, T5, T6, T7, T8, T9] -class TestPrivate(object): +class TestPrivate: def test__cseries_to_zseries(self): for i in range(5): @@ -47,7 +45,7 @@ class TestPrivate(object): assert_equal(res, tgt) -class TestConstants(object): +class TestConstants: def test_chebdomain(self): assert_equal(cheb.chebdomain, [-1, 1]) @@ -62,12 +60,12 @@ class TestConstants(object): assert_equal(cheb.chebx, [0, 1]) -class TestArithmetic(object): +class TestArithmetic: def test_chebadd(self): for i in range(5): for j in range(5): - msg = "At i=%d, j=%d" % (i, j) + msg = f"At i={i}, j={j}" tgt = np.zeros(max(i, j) + 1) tgt[i] += 1 tgt[j] += 1 @@ -77,7 +75,7 @@ class TestArithmetic(object): def test_chebsub(self): for i in range(5): for j in range(5): - msg = "At i=%d, j=%d" % (i, j) + msg = f"At i={i}, j={j}" tgt = np.zeros(max(i, j) + 1) tgt[i] += 1 tgt[j] -= 1 @@ -95,7 +93,7 @@ class TestArithmetic(object): def test_chebmul(self): for i in range(5): for j in range(5): - msg = "At i=%d, j=%d" % (i, j) + msg = f"At i={i}, j={j}" tgt = np.zeros(i + j + 1) tgt[i + j] += .5 tgt[abs(i - j)] += .5 @@ -105,7 +103,7 @@ class TestArithmetic(object): def test_chebdiv(self): for i in range(5): for j in range(5): - msg = "At i=%d, j=%d" % (i, j) + msg = f"At i={i}, j={j}" ci = [0]*i + [1] cj = [0]*j + [1] tgt = cheb.chebadd(ci, cj) @@ -116,14 +114,14 @@ class TestArithmetic(object): def test_chebpow(self): for i in range(5): for j in range(5): - msg = "At i=%d, j=%d" % (i, j) + msg = f"At i={i}, j={j}" c = np.arange(i + 1) tgt = reduce(cheb.chebmul, [c]*j, np.array([1])) res = cheb.chebpow(c, j) assert_equal(trim(res), trim(tgt), err_msg=msg) -class TestEvaluation(object): +class TestEvaluation: # coefficients of 1 + 2*x + 3*x**2 c1d = np.array([2.5, 2., 1.5]) c2d = np.einsum('i,j->ij', c1d, c1d) @@ -141,7 +139,7 @@ class TestEvaluation(object): x = np.linspace(-1, 1) y = [polyval(x, c) for c in Tlist] for i in range(10): - msg = "At i=%d" % i + msg = f"At i={i}" tgt = y[i] res = cheb.chebval(x, [0]*i + [1]) assert_almost_equal(res, tgt, err_msg=msg) @@ -217,7 +215,7 @@ class TestEvaluation(object): assert_(res.shape == (2, 3)*3) -class TestIntegral(object): +class TestIntegral: def test_chebint(self): # check exceptions @@ -319,7 +317,7 @@ class TestIntegral(object): assert_almost_equal(res, tgt) -class TestDerivative(object): +class TestDerivative: def test_chebder(self): # check exceptions @@ -359,7 +357,7 @@ class TestDerivative(object): assert_almost_equal(res, tgt) -class TestVander(object): +class TestVander: # some random values in [-1, 1) x = np.random.random((3, 5))*2 - 1 @@ -407,7 +405,7 @@ class TestVander(object): assert_(van.shape == (1, 5, 24)) -class TestFitting(object): +class TestFitting: def test_chebfit(self): def f(x): @@ -484,7 +482,7 @@ class TestFitting(object): assert_almost_equal(coef1, coef2) -class TestInterpolate(object): +class TestInterpolate: def f(self, x): return x * (x - 1) * (x - 2) @@ -509,7 +507,7 @@ class TestInterpolate(object): assert_almost_equal(cheb.chebval(x, c), powx(x, p), decimal=12) -class TestCompanion(object): +class TestCompanion: def test_raises(self): assert_raises(ValueError, cheb.chebcompanion, []) @@ -524,7 +522,7 @@ class TestCompanion(object): assert_(cheb.chebcompanion([1, 2])[0, 0] == -.5) -class TestGauss(object): +class TestGauss: def test_100(self): x, w = cheb.chebgauss(100) @@ -543,7 +541,7 @@ class TestGauss(object): assert_almost_equal(w.sum(), tgt) -class TestMisc(object): +class TestMisc: def test_chebfromroots(self): res = cheb.chebfromroots([]) |