diff options
Diffstat (limited to 'numpy/polynomial/tests/test_chebyshev.py')
| -rw-r--r-- | numpy/polynomial/tests/test_chebyshev.py | 68 |
1 files changed, 34 insertions, 34 deletions
diff --git a/numpy/polynomial/tests/test_chebyshev.py b/numpy/polynomial/tests/test_chebyshev.py index 367d81f58..70eccdd0a 100644 --- a/numpy/polynomial/tests/test_chebyshev.py +++ b/numpy/polynomial/tests/test_chebyshev.py @@ -64,8 +64,8 @@ class TestArithmetic(TestCase) : def test_chebadd(self) : for i in range(5) : for j in range(5) : - msg = "At i=%d, j=%d" % (i,j) - tgt = np.zeros(max(i,j) + 1) + msg = "At i=%d, j=%d" % (i, j) + tgt = np.zeros(max(i, j) + 1) tgt[i] += 1 tgt[j] += 1 res = cheb.chebadd([0]*i + [1], [0]*j + [1]) @@ -74,8 +74,8 @@ class TestArithmetic(TestCase) : def test_chebsub(self) : for i in range(5) : for j in range(5) : - msg = "At i=%d, j=%d" % (i,j) - tgt = np.zeros(max(i,j) + 1) + msg = "At i=%d, j=%d" % (i, j) + tgt = np.zeros(max(i, j) + 1) tgt[i] += 1 tgt[j] -= 1 res = cheb.chebsub([0]*i + [1], [0]*j + [1]) @@ -83,7 +83,7 @@ class TestArithmetic(TestCase) : def test_chebmulx(self): assert_equal(cheb.chebmulx([0]), [0]) - assert_equal(cheb.chebmulx([1]), [0,1]) + assert_equal(cheb.chebmulx([1]), [0, 1]) for i in range(1, 5): ser = [0]*i + [1] tgt = [0]*(i - 1) + [.5, 0, .5] @@ -92,7 +92,7 @@ class TestArithmetic(TestCase) : def test_chebmul(self) : for i in range(5) : for j in range(5) : - msg = "At i=%d, j=%d" % (i,j) + msg = "At i=%d, j=%d" % (i, j) tgt = np.zeros(i + j + 1) tgt[i + j] += .5 tgt[abs(i - j)] += .5 @@ -102,7 +102,7 @@ class TestArithmetic(TestCase) : def test_chebdiv(self) : for i in range(5) : for j in range(5) : - msg = "At i=%d, j=%d" % (i,j) + msg = "At i=%d, j=%d" % (i, j) ci = [0]*i + [1] cj = [0]*j + [1] tgt = cheb.chebadd(ci, cj) @@ -127,7 +127,7 @@ class TestEvaluation(TestCase): assert_equal(cheb.chebval([], [1]).size, 0) #check normal input) - x = np.linspace(-1,1) + x = np.linspace(-1, 1) y = [polyval(x, c) for c in Tlist] for i in range(10) : msg = "At i=%d" % i @@ -140,8 +140,8 @@ class TestEvaluation(TestCase): dims = [2]*i x = np.zeros(dims) assert_equal(cheb.chebval(x, [1]).shape, dims) - assert_equal(cheb.chebval(x, [1,0]).shape, dims) - assert_equal(cheb.chebval(x, [1,0,0]).shape, dims) + assert_equal(cheb.chebval(x, [1, 0]).shape, dims) + assert_equal(cheb.chebval(x, [1, 0, 0]).shape, dims) def test_chebval2d(self): x1, x2, x3 = self.x @@ -156,9 +156,9 @@ class TestEvaluation(TestCase): assert_almost_equal(res, tgt) #test shape - z = np.ones((2,3)) + z = np.ones((2, 3)) res = cheb.chebval2d(z, z, self.c2d) - assert_(res.shape == (2,3)) + assert_(res.shape == (2, 3)) def test_chebval3d(self): x1, x2, x3 = self.x @@ -173,9 +173,9 @@ class TestEvaluation(TestCase): assert_almost_equal(res, tgt) #test shape - z = np.ones((2,3)) + z = np.ones((2, 3)) res = cheb.chebval3d(z, z, z, self.c3d) - assert_(res.shape == (2,3)) + assert_(res.shape == (2, 3)) def test_chebgrid2d(self): x1, x2, x3 = self.x @@ -187,7 +187,7 @@ class TestEvaluation(TestCase): assert_almost_equal(res, tgt) #test shape - z = np.ones((2,3)) + z = np.ones((2, 3)) res = cheb.chebgrid2d(z, z, self.c2d) assert_(res.shape == (2, 3)*2) @@ -201,7 +201,7 @@ class TestEvaluation(TestCase): assert_almost_equal(res, tgt) #test shape - z = np.ones((2,3)) + z = np.ones((2, 3)) res = cheb.chebgrid3d(z, z, z, self.c3d) assert_(res.shape == (2, 3)*3) @@ -212,7 +212,7 @@ class TestIntegral(TestCase) : # check exceptions assert_raises(ValueError, cheb.chebint, [0], .5) assert_raises(ValueError, cheb.chebint, [0], -1) - assert_raises(ValueError, cheb.chebint, [0], 1, [0,0]) + assert_raises(ValueError, cheb.chebint, [0], 1, [0, 0]) # test integration of zero polynomial for i in range(2, 5): @@ -250,7 +250,7 @@ class TestIntegral(TestCase) : # check multiple integrations with default k for i in range(5) : - for j in range(2,5) : + for j in range(2, 5) : pol = [0]*i + [1] tgt = pol[:] for k in range(j) : @@ -260,7 +260,7 @@ class TestIntegral(TestCase) : # check multiple integrations with defined k for i in range(5) : - for j in range(2,5) : + for j in range(2, 5) : pol = [0]*i + [1] tgt = pol[:] for k in range(j) : @@ -270,7 +270,7 @@ class TestIntegral(TestCase) : # check multiple integrations with lbnd for i in range(5) : - for j in range(2,5) : + for j in range(2, 5) : pol = [0]*i + [1] tgt = pol[:] for k in range(j) : @@ -280,7 +280,7 @@ class TestIntegral(TestCase) : # check multiple integrations with scaling for i in range(5) : - for j in range(2,5) : + for j in range(2, 5) : pol = [0]*i + [1] tgt = pol[:] for k in range(j) : @@ -320,14 +320,14 @@ class TestDerivative(TestCase) : # check that derivation is the inverse of integration for i in range(5) : - for j in range(2,5) : + for j in range(2, 5) : tgt = [0]*i + [1] res = cheb.chebder(cheb.chebint(tgt, m=j), m=j) assert_almost_equal(trim(res), trim(tgt)) # check derivation with scaling for i in range(5) : - for j in range(2,5) : + for j in range(2, 5) : tgt = [0]*i + [1] res = cheb.chebder(cheb.chebint(tgt, m=j, scl=2), m=j, scl=.5) assert_almost_equal(trim(res), trim(tgt)) @@ -409,10 +409,10 @@ class TestFitting(TestCase): assert_raises(TypeError, cheb.chebfit, [1, 2], [1], 0) assert_raises(TypeError, cheb.chebfit, [1], [1, 2], 0) assert_raises(TypeError, cheb.chebfit, [1], [1], 0, w=[[1]]) - assert_raises(TypeError, cheb.chebfit, [1], [1], 0, w=[1,1]) + assert_raises(TypeError, cheb.chebfit, [1], [1], 0, w=[1, 1]) # Test fit - x = np.linspace(0,2) + x = np.linspace(0, 2) y = f(x) # coef3 = cheb.chebfit(x, y, 3) @@ -423,8 +423,8 @@ class TestFitting(TestCase): assert_equal(len(coef4), 5) assert_almost_equal(cheb.chebval(x, coef4), y) # - coef2d = cheb.chebfit(x, np.array([y,y]).T, 3) - assert_almost_equal(coef2d, np.array([coef3,coef3]).T) + coef2d = cheb.chebfit(x, np.array([y, y]).T, 3) + assert_almost_equal(coef2d, np.array([coef3, coef3]).T) # test weighting w = np.zeros_like(x) yw = y.copy() @@ -433,8 +433,8 @@ class TestFitting(TestCase): wcoef3 = cheb.chebfit(x, yw, 3, w=w) assert_almost_equal(wcoef3, coef3) # - wcoef2d = cheb.chebfit(x, np.array([yw,yw]).T, 3, w=w) - assert_almost_equal(wcoef2d, np.array([coef3,coef3]).T) + wcoef2d = cheb.chebfit(x, np.array([yw, yw]).T, 3, w=w) + assert_almost_equal(wcoef2d, np.array([coef3, coef3]).T) # test scaling with complex values x points whose square # is zero when summed. x = [1, 1j, -1, -1j] @@ -467,7 +467,7 @@ class TestGauss(TestCase): v = cheb.chebvander(x, 99) vv = np.dot(v.T * w, v) vd = 1/np.sqrt(vv.diagonal()) - vv = vd[:,None] * vv * vd + vv = vd[:, None] * vv * vd assert_almost_equal(vv, np.eye(100)) # check that the integral of 1 is correct @@ -480,16 +480,16 @@ class TestMisc(TestCase) : def test_chebfromroots(self) : res = cheb.chebfromroots([]) assert_almost_equal(trim(res), [1]) - for i in range(1,5) : + for i in range(1, 5) : roots = np.cos(np.linspace(-np.pi, 0, 2*i + 1)[1::2]) tgt = [0]*i + [1] res = cheb.chebfromroots(roots)*2**(i-1) - assert_almost_equal(trim(res),trim(tgt)) + assert_almost_equal(trim(res), trim(tgt)) def test_chebroots(self) : assert_almost_equal(cheb.chebroots([1]), []) assert_almost_equal(cheb.chebroots([1, 2]), [-.5]) - for i in range(2,5) : + for i in range(2, 5) : tgt = np.linspace(-1, 1, i) res = cheb.chebroots(cheb.chebfromroots(tgt)) assert_almost_equal(trim(res), trim(tgt)) @@ -506,7 +506,7 @@ class TestMisc(TestCase) : assert_equal(cheb.chebtrim(coef, 2), [0]) def test_chebline(self) : - assert_equal(cheb.chebline(3,4), [3, 4]) + assert_equal(cheb.chebline(3, 4), [3, 4]) def test_cheb2poly(self) : for i in range(10) : |
