summaryrefslogtreecommitdiff
path: root/numpy/polynomial/tests/test_chebyshev.py
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/polynomial/tests/test_chebyshev.py')
-rw-r--r--numpy/polynomial/tests/test_chebyshev.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/numpy/polynomial/tests/test_chebyshev.py b/numpy/polynomial/tests/test_chebyshev.py
index 2e4344731..74701af1a 100644
--- a/numpy/polynomial/tests/test_chebyshev.py
+++ b/numpy/polynomial/tests/test_chebyshev.py
@@ -471,6 +471,26 @@ class TestFitting(object):
assert_almost_equal(coef1, coef2)
+class TestInterp(object):
+
+ @staticmethod
+ def f(x):
+ return x * (x - 1) * (x - 2)
+
+ def test_raises(self):
+ assert_raises(ValueError, cheb.chebinterp, self.f, -1, [-1, 1])
+ assert_raises(ValueError, cheb.chebinterp, self.f, 10.1, [-1, 1])
+
+ def test_dimensions(self):
+ for i in range(1, 5):
+ assert_(cheb.chebinterp(self.f, i, [-1, 1]).shape == (i+1,))
+
+ def test_approx(self):
+ assert_almost_equal(cheb.chebinterp(lambda x: [1, 1, 1, 1], 3, [-1, 1]), np.array([1, 0, 0, 0]))
+ assert_almost_equal(cheb.chebinterp(lambda x: x, 3, [-1, 1]), np.array([0, 1, 0, 0]))
+ assert_almost_equal(cheb.chebinterp(self.f, 3, [-1, 1]), np.array([-3/2, 11/4, -3/2, 1/4]))
+
+
class TestCompanion(object):
def test_raises(self):