From af79cde3ecc5a7bf6b14c97698cad08f2bde82b8 Mon Sep 17 00:00:00 2001 From: Charles Harris Date: Fri, 21 May 2010 05:36:05 +0000 Subject: CHG: Change the truncate method of the Chebyshev and Polynomial classes to take degree instead of length. This seems to fit better with normal usage. I feel this change is safe at this time because these new classes seem to be little used as yet. --- numpy/polynomial/tests/test_chebyshev.py | 9 +++++---- numpy/polynomial/tests/test_polynomial.py | 9 +++++---- 2 files changed, 10 insertions(+), 8 deletions(-) (limited to 'numpy/polynomial/tests') diff --git a/numpy/polynomial/tests/test_chebyshev.py b/numpy/polynomial/tests/test_chebyshev.py index 6f42d06b9..b2c4ee105 100644 --- a/numpy/polynomial/tests/test_chebyshev.py +++ b/numpy/polynomial/tests/test_chebyshev.py @@ -416,11 +416,12 @@ class TestChebyshevClass(TestCase) : assert_equal(p.trim(1e-5).coef, coef[:1]) def test_truncate(self) : - assert_raises(ValueError, self.p1.truncate, 0) - assert_equal(len(self.p1.truncate(4)), 3) + assert_raises(ValueError, self.p1.truncate, .5) + assert_raises(ValueError, self.p1.truncate, -1) assert_equal(len(self.p1.truncate(3)), 3) - assert_equal(len(self.p1.truncate(2)), 2) - assert_equal(len(self.p1.truncate(1)), 1) + assert_equal(len(self.p1.truncate(2)), 3) + assert_equal(len(self.p1.truncate(1)), 2) + assert_equal(len(self.p1.truncate(0)), 1) def test_copy(self) : p = self.p1.copy() diff --git a/numpy/polynomial/tests/test_polynomial.py b/numpy/polynomial/tests/test_polynomial.py index 34a3d10f3..7ba5b6c8f 100644 --- a/numpy/polynomial/tests/test_polynomial.py +++ b/numpy/polynomial/tests/test_polynomial.py @@ -390,11 +390,12 @@ class TestPolynomialClass(TestCase) : assert_equal(p.trim(1e-5).coef, coef[:1]) def test_truncate(self) : - assert_raises(ValueError, self.p1.truncate, 0) - assert_equal(len(self.p1.truncate(4)), 3) + assert_raises(ValueError, self.p1.truncate, .5) + assert_raises(ValueError, self.p1.truncate, -1) assert_equal(len(self.p1.truncate(3)), 3) - assert_equal(len(self.p1.truncate(2)), 2) - assert_equal(len(self.p1.truncate(1)), 1) + assert_equal(len(self.p1.truncate(2)), 3) + assert_equal(len(self.p1.truncate(1)), 2) + assert_equal(len(self.p1.truncate(0)), 1) def test_copy(self) : p = self.p1.copy() -- cgit v1.2.1