# [Numpy-svn] r8268 - in branches/1.4.x/numpy/polynomial: . tests

numpy-svn@scip... numpy-svn@scip...
Sat Feb 27 01:59:34 CST 2010

```Author: charris
Date: 2010-02-27 01:59:34 -0600 (Sat, 27 Feb 2010)
New Revision: 8268

Modified:
branches/1.4.x/numpy/polynomial/polytemplate.py
branches/1.4.x/numpy/polynomial/tests/test_chebyshev.py
branches/1.4.x/numpy/polynomial/tests/test_polynomial.py
Log:
BUG: Fix lower bound specification for integration in the Chebyshev and
Polynomial classes and add some tests.

Modified: branches/1.4.x/numpy/polynomial/polytemplate.py
===================================================================
--- branches/1.4.x/numpy/polynomial/polytemplate.py	2010-02-25 17:49:24 UTC (rev 8267)
+++ branches/1.4.x/numpy/polynomial/polytemplate.py	2010-02-27 07:59:34 UTC (rev 8268)
@@ -441,12 +441,12 @@
`\${nick}der` : similar function for derivative.

"""
-        off, scl = pu.mapparms(\$domain, self.domain)
+        off, scl = self.mapparms()
if lbnd is None :
lbnd = 0
else :
-            lbnd = off + scl*x
-        coef = \${nick}int(self.coef, m, k, lbnd, scl)
+            lbnd = off + scl*lbnd
+        coef = \${nick}int(self.coef, m, k, lbnd, 1./scl)
return self.__class__(coef, self.domain)

def deriv(self, m=1):
@@ -472,7 +472,7 @@
`\${nick}int` : similar function for integration.

"""
-        off, scl = pu.mapparms(self.domain, \$domain)
+        off, scl = self.mapparms()
coef = \${nick}der(self.coef, m, scl)
return self.__class__(coef, self.domain)

Modified: branches/1.4.x/numpy/polynomial/tests/test_chebyshev.py
===================================================================
--- branches/1.4.x/numpy/polynomial/tests/test_chebyshev.py	2010-02-25 17:49:24 UTC (rev 8267)
+++ branches/1.4.x/numpy/polynomial/tests/test_chebyshev.py	2010-02-27 07:59:34 UTC (rev 8268)
@@ -105,7 +105,7 @@
return x*(x**2 - 1)

#check empty input
-        assert_equal(ch.chebval([], 1).size, 0)
+        assert_equal(ch.chebval([], [1]).size, 0)

#check normal input)
for i in range(5) :
@@ -420,6 +420,8 @@
def test_integ(self) :
p = self.p2.integ()
assert_almost_equal(p.coef, ch.chebint([1,2,3], 1, 0, scl=.5))
+        p = self.p2.integ(lbnd=0)
+        assert_almost_equal(p(0), 0)
p = self.p2.integ(1, 1)
assert_almost_equal(p.coef, ch.chebint([1,2,3], 1, 1, scl=.5))
p = self.p2.integ(2, [1, 2])

Modified: branches/1.4.x/numpy/polynomial/tests/test_polynomial.py
===================================================================
--- branches/1.4.x/numpy/polynomial/tests/test_polynomial.py	2010-02-25 17:49:24 UTC (rev 8267)
+++ branches/1.4.x/numpy/polynomial/tests/test_polynomial.py	2010-02-27 07:59:34 UTC (rev 8268)
@@ -97,7 +97,7 @@
return x*(x**2 - 1)

#check empty input
-        assert_equal(poly.polyval([], 1).size, 0)
+        assert_equal(poly.polyval([], [1]).size, 0)

#check normal input)
x = np.linspace(-1,1)
@@ -394,6 +394,8 @@
def test_integ(self) :
p = self.p2.integ()
assert_almost_equal(p.coef, poly.polyint([1,2,3], 1, 0, scl=.5))
+        p = self.p2.integ(lbnd=0)
+        assert_almost_equal(p(0), 0)
p = self.p2.integ(1, 1)
assert_almost_equal(p.coef, poly.polyint([1,2,3], 1, 1, scl=.5))
p = self.p2.integ(2, [1, 2])

```