summaryrefslogtreecommitdiff
path: root/numpy/polynomial/tests/test_chebyshev.py
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2011-12-23 15:33:59 -0700
committerCharles Harris <charlesr.harris@gmail.com>2012-01-09 10:45:14 -0700
commit8ad18ab3799d669d93759e7c20ff6457ed1e2bc2 (patch)
tree2bd733f9932b5f52cdb0d0088283fa967f8d4853 /numpy/polynomial/tests/test_chebyshev.py
parenta76c3339a9c1f869ec0c5dff7b0379828b3c8598 (diff)
downloadnumpy-8ad18ab3799d669d93759e7c20ff6457ed1e2bc2.tar.gz
TST: Add tests for basis and cast static class methods.
A new test file, test_classes, has been added so that conversions between all the class types can be tested. Several tests common to all the classes were also moved to this file. Ideally all the common tests will be moved, but that isn't done yet.
Diffstat (limited to 'numpy/polynomial/tests/test_chebyshev.py')
-rw-r--r--numpy/polynomial/tests/test_chebyshev.py64
1 files changed, 1 insertions, 63 deletions
diff --git a/numpy/polynomial/tests/test_chebyshev.py b/numpy/polynomial/tests/test_chebyshev.py
index 56d720f2d..95d241d94 100644
--- a/numpy/polynomial/tests/test_chebyshev.py
+++ b/numpy/polynomial/tests/test_chebyshev.py
@@ -617,9 +617,6 @@ class TestChebyshevClass(TestCase) :
xx = 2*x - 1
assert_almost_equal(self.p2(x), self.p1(xx))
- def test_degree(self) :
- assert_equal(self.p1.degree(), 2)
-
def test_cutdeg(self) :
assert_raises(ValueError, self.p1.cutdeg, .5)
assert_raises(ValueError, self.p1.cutdeg, -1)
@@ -628,11 +625,6 @@ class TestChebyshevClass(TestCase) :
assert_equal(len(self.p1.cutdeg(1)), 2)
assert_equal(len(self.p1.cutdeg(0)), 1)
- def test_convert(self) :
- x = np.linspace(-1,1)
- p = self.p1.convert(domain=[0,1])
- assert_almost_equal(p(x), self.p1(x))
-
def test_mapparms(self) :
parms = self.p2.mapparms()
assert_almost_equal(parms, [-1, 2])
@@ -652,10 +644,6 @@ class TestChebyshevClass(TestCase) :
assert_equal(len(self.p1.truncate(2)), 2)
assert_equal(len(self.p1.truncate(1)), 1)
- def test_copy(self) :
- p = self.p1.copy()
- assert_(self.p1 == p)
-
def test_integ(self) :
p = self.p2.integ()
assert_almost_equal(p.coef, cheb.chebint([1,2,3], 1, 0, scl=.5))
@@ -666,63 +654,13 @@ class TestChebyshevClass(TestCase) :
p = self.p2.integ(2, [1, 2])
assert_almost_equal(p.coef, cheb.chebint([1,2,3], 2, [1,2], scl=.5))
- def test_deriv(self) :
- p = self.p2.integ(2, [1, 2])
- assert_almost_equal(p.deriv(1).coef, self.p2.integ(1, [1]).coef)
- assert_almost_equal(p.deriv(2).coef, self.p2.coef)
-
- def test_roots(self) :
- p = cheb.Chebyshev(cheb.poly2cheb([0, -1, 0, 1]), [0, 1])
- res = p.roots()
- tgt = [0, .5, 1]
- assert_almost_equal(res, tgt)
-
- def test_linspace(self):
- xdes = np.linspace(0, 1, 20)
- ydes = self.p2(xdes)
- xres, yres = self.p2.linspace(20)
- assert_almost_equal(xres, xdes)
- assert_almost_equal(yres, ydes)
-
- def test_fromroots(self) :
- roots = [0, .5, 1]
- p = cheb.Chebyshev.fromroots(roots, domain=[0, 1])
- res = p.coef
- tgt = cheb.poly2cheb([0, -1, 0, 1])
- assert_almost_equal(res, tgt)
-
- def test_fit(self) :
- def f(x) :
- return x*(x - 1)*(x - 2)
- x = np.linspace(0,3)
- y = f(x)
-
- # test default value of domain
- p = cheb.Chebyshev.fit(x, y, 3)
- assert_almost_equal(p.domain, [0,3])
-
- # test that fit works in given domains
- p = cheb.Chebyshev.fit(x, y, 3, None)
- assert_almost_equal(p(x), y)
- assert_almost_equal(p.domain, [0,3])
- p = cheb.Chebyshev.fit(x, y, 3, [])
- assert_almost_equal(p(x), y)
- assert_almost_equal(p.domain, [-1, 1])
- # test that fit accepts weights.
- w = np.zeros_like(x)
- yw = y.copy()
- w[1::2] = 1
- yw[0::2] = 0
- p = cheb.Chebyshev.fit(x, yw, 3, w=w)
- assert_almost_equal(p(x), y)
-
def test_identity(self) :
x = np.linspace(0,3)
p = cheb.Chebyshev.identity()
assert_almost_equal(p(x), x)
p = cheb.Chebyshev.identity([1,3])
assert_almost_equal(p(x), x)
-#
+
if __name__ == "__main__":
run_module_suite()