diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2011-12-23 15:33:59 -0700 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2012-01-09 10:45:14 -0700 |
commit | 8ad18ab3799d669d93759e7c20ff6457ed1e2bc2 (patch) | |
tree | 2bd733f9932b5f52cdb0d0088283fa967f8d4853 /numpy/polynomial/tests/test_legendre.py | |
parent | a76c3339a9c1f869ec0c5dff7b0379828b3c8598 (diff) | |
download | numpy-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_legendre.py')
-rw-r--r-- | numpy/polynomial/tests/test_legendre.py | 64 |
1 files changed, 1 insertions, 63 deletions
diff --git a/numpy/polynomial/tests/test_legendre.py b/numpy/polynomial/tests/test_legendre.py index d7bb238a9..4dc4f9a25 100644 --- a/numpy/polynomial/tests/test_legendre.py +++ b/numpy/polynomial/tests/test_legendre.py @@ -580,9 +580,6 @@ class TestLegendreClass(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) @@ -591,11 +588,6 @@ class TestLegendreClass(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]) @@ -615,10 +607,6 @@ class TestLegendreClass(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, leg.legint([1,2,3], 1, 0, scl=.5)) @@ -629,63 +617,13 @@ class TestLegendreClass(TestCase) : p = self.p2.integ(2, [1, 2]) assert_almost_equal(p.coef, leg.legint([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 = leg.Legendre(leg.poly2leg([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 = leg.Legendre.fromroots(roots, domain=[0, 1]) - res = p.coef - tgt = leg.poly2leg([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 = leg.Legendre.fit(x, y, 3) - assert_almost_equal(p.domain, [0,3]) - - # test that fit works in given domains - p = leg.Legendre.fit(x, y, 3, None) - assert_almost_equal(p(x), y) - assert_almost_equal(p.domain, [0,3]) - p = leg.Legendre.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 = leg.Legendre.fit(x, yw, 3, w=w) - assert_almost_equal(p(x), y) - def test_identity(self) : x = np.linspace(0,3) p = leg.Legendre.identity() assert_almost_equal(p(x), x) p = leg.Legendre.identity([1,3]) assert_almost_equal(p(x), x) -# + if __name__ == "__main__": run_module_suite() |