summaryrefslogtreecommitdiff
path: root/numpy/polynomial
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2014-07-29 22:35:28 -0600
committerCharles Harris <charlesr.harris@gmail.com>2014-07-29 22:58:58 -0600
commitf9c6398d4f021e9509e19157a0d5ee72b27a8c2a (patch)
tree4f84dc32377f8eed179692ab709e769836d70857 /numpy/polynomial
parent02f922b6e89ff6efe9c073249afb1f803a1dfa6e (diff)
downloadnumpy-f9c6398d4f021e9509e19157a0d5ee72b27a8c2a.tar.gz
MAINT: Fix blemishes in numpy/polynomial/tests revealed by pyflakes.
Diffstat (limited to 'numpy/polynomial')
-rw-r--r--numpy/polynomial/tests/test_classes.py28
-rw-r--r--numpy/polynomial/tests/test_hermite.py1
-rw-r--r--numpy/polynomial/tests/test_hermite_e.py5
-rw-r--r--numpy/polynomial/tests/test_laguerre.py1
-rw-r--r--numpy/polynomial/tests/test_legendre.py1
-rw-r--r--numpy/polynomial/tests/test_polyutils.py8
6 files changed, 31 insertions, 13 deletions
diff --git a/numpy/polynomial/tests/test_classes.py b/numpy/polynomial/tests/test_classes.py
index f9134b8c1..cd5a54687 100644
--- a/numpy/polynomial/tests/test_classes.py
+++ b/numpy/polynomial/tests/test_classes.py
@@ -10,12 +10,10 @@ from numbers import Number
import numpy as np
from numpy.polynomial import (
- Polynomial, Legendre, Chebyshev, Laguerre,
- Hermite, HermiteE)
+ Polynomial, Legendre, Chebyshev, Laguerre, Hermite, HermiteE)
from numpy.testing import (
- TestCase, assert_almost_equal, assert_raises,
- assert_equal, assert_, run_module_suite, dec)
-from numpy.testing.noseclasses import KnownFailure
+ assert_almost_equal, assert_raises, assert_equal, assert_,
+ run_module_suite)
from numpy.compat import long
@@ -410,6 +408,9 @@ def check_roots(Poly):
d = Poly.domain + random((2,))*.25
w = Poly.window + random((2,))*.25
tgt = np.sort(random((5,)))
+ res = np.sort(Poly.fromroots(tgt, domain=d, window=w).roots())
+ assert_almost_equal(res, tgt)
+ # default domain and window
res = np.sort(Poly.fromroots(tgt).roots())
assert_almost_equal(res, tgt)
@@ -468,6 +469,12 @@ def check_deriv(Poly):
p3 = p1.integ(1, k=[1])
assert_almost_equal(p2.deriv(1).coef, p3.coef)
assert_almost_equal(p2.deriv(2).coef, p1.coef)
+ # default domain and window
+ p1 = Poly([1, 2, 3])
+ p2 = p1.integ(2, k=[1, 2])
+ p3 = p1.integ(1, k=[1])
+ assert_almost_equal(p2.deriv(1).coef, p3.coef)
+ assert_almost_equal(p2.deriv(2).coef, p1.coef)
def check_linspace(Poly):
@@ -491,11 +498,18 @@ def check_linspace(Poly):
def check_pow(Poly):
d = Poly.domain + random((2,))*.25
w = Poly.window + random((2,))*.25
- tgt = Poly([1], domain=d, window=d)
- tst = Poly([1, 2, 3], domain=d, window=d)
+ tgt = Poly([1], domain=d, window=w)
+ tst = Poly([1, 2, 3], domain=d, window=w)
+ for i in range(5):
+ assert_poly_almost_equal(tst**i, tgt)
+ tgt = tgt * tst
+ # default domain and window
+ tgt = Poly([1])
+ tst = Poly([1, 2, 3])
for i in range(5):
assert_poly_almost_equal(tst**i, tgt)
tgt = tgt * tst
+ # check error for invalid powers
assert_raises(ValueError, op.pow, tgt, 1.5)
assert_raises(ValueError, op.pow, tgt, -1)
diff --git a/numpy/polynomial/tests/test_hermite.py b/numpy/polynomial/tests/test_hermite.py
index 8817007a7..e67625a88 100644
--- a/numpy/polynomial/tests/test_hermite.py
+++ b/numpy/polynomial/tests/test_hermite.py
@@ -119,7 +119,6 @@ class TestEvaluation(TestCase):
y = [polyval(x, c) for c in Hlist]
for i in range(10):
msg = "At i=%d" % i
- ser = np.zeros
tgt = y[i]
res = herm.hermval(x, [0]*i + [1])
assert_almost_equal(res, tgt, err_msg=msg)
diff --git a/numpy/polynomial/tests/test_hermite_e.py b/numpy/polynomial/tests/test_hermite_e.py
index 315b54173..f8601a828 100644
--- a/numpy/polynomial/tests/test_hermite_e.py
+++ b/numpy/polynomial/tests/test_hermite_e.py
@@ -6,7 +6,9 @@ from __future__ import division, absolute_import, print_function
import numpy as np
import numpy.polynomial.hermite_e as herme
from numpy.polynomial.polynomial import polyval
-from numpy.testing import *
+from numpy.testing import (
+ TestCase, assert_almost_equal, assert_raises,
+ assert_equal, assert_, run_module_suite)
He0 = np.array([1])
He1 = np.array([0, 1])
@@ -117,7 +119,6 @@ class TestEvaluation(TestCase):
y = [polyval(x, c) for c in Helist]
for i in range(10):
msg = "At i=%d" % i
- ser = np.zeros
tgt = y[i]
res = herme.hermeval(x, [0]*i + [1])
assert_almost_equal(res, tgt, err_msg=msg)
diff --git a/numpy/polynomial/tests/test_laguerre.py b/numpy/polynomial/tests/test_laguerre.py
index 768ae53d3..1dc57a960 100644
--- a/numpy/polynomial/tests/test_laguerre.py
+++ b/numpy/polynomial/tests/test_laguerre.py
@@ -116,7 +116,6 @@ class TestEvaluation(TestCase):
y = [polyval(x, c) for c in Llist]
for i in range(7):
msg = "At i=%d" % i
- ser = np.zeros
tgt = y[i]
res = lag.lagval(x, [0]*i + [1])
assert_almost_equal(res, tgt, err_msg=msg)
diff --git a/numpy/polynomial/tests/test_legendre.py b/numpy/polynomial/tests/test_legendre.py
index 760d16e25..8ac1feb58 100644
--- a/numpy/polynomial/tests/test_legendre.py
+++ b/numpy/polynomial/tests/test_legendre.py
@@ -120,7 +120,6 @@ class TestEvaluation(TestCase):
y = [polyval(x, c) for c in Llist]
for i in range(10):
msg = "At i=%d" % i
- ser = np.zeros
tgt = y[i]
res = leg.legval(x, [0]*i + [1])
assert_almost_equal(res, tgt, err_msg=msg)
diff --git a/numpy/polynomial/tests/test_polyutils.py b/numpy/polynomial/tests/test_polyutils.py
index c77ee2435..974e2e09a 100644
--- a/numpy/polynomial/tests/test_polyutils.py
+++ b/numpy/polynomial/tests/test_polyutils.py
@@ -5,7 +5,9 @@ from __future__ import division, absolute_import, print_function
import numpy as np
import numpy.polynomial.polyutils as pu
-from numpy.testing import *
+from numpy.testing import (
+ TestCase, assert_almost_equal, assert_raises,
+ assert_equal, assert_, run_module_suite)
class TestMisc(TestCase):
@@ -101,3 +103,7 @@ class TestDomain(TestCase):
tgt = [-1 + 1j, 1 - 1j]
res = pu.mapparms(dom1, dom2)
assert_almost_equal(res, tgt)
+
+
+if __name__ == "__main__":
+ run_module_suite()