summaryrefslogtreecommitdiff
path: root/numpy/polynomial
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2018-08-30 11:18:24 -0500
committerGitHub <noreply@github.com>2018-08-30 11:18:24 -0500
commit9a4120b04d2f8d40c59fe32c17db0bcbfb64bd9b (patch)
treec87ddb6801b6927b257ae835f744051fd78d60c8 /numpy/polynomial
parentfdbf432bd9930727afbf844b226e6f8302c0cc04 (diff)
parent4c8e91e6ad07fcae15888ae9c78338f37f3d77ae (diff)
downloadnumpy-9a4120b04d2f8d40c59fe32c17db0bcbfb64bd9b.tar.gz
Merge pull request #11818 from jeffyancey/polynomial-tests
TST: add missing tests for all polynomial subclass pow fns.
Diffstat (limited to 'numpy/polynomial')
-rw-r--r--numpy/polynomial/tests/test_chebyshev.py11
-rw-r--r--numpy/polynomial/tests/test_hermite.py11
-rw-r--r--numpy/polynomial/tests/test_hermite_e.py11
-rw-r--r--numpy/polynomial/tests/test_laguerre.py11
-rw-r--r--numpy/polynomial/tests/test_legendre.py11
-rw-r--r--numpy/polynomial/tests/test_polynomial.py11
6 files changed, 66 insertions, 0 deletions
diff --git a/numpy/polynomial/tests/test_chebyshev.py b/numpy/polynomial/tests/test_chebyshev.py
index 439dfa08d..7fb7492c6 100644
--- a/numpy/polynomial/tests/test_chebyshev.py
+++ b/numpy/polynomial/tests/test_chebyshev.py
@@ -3,6 +3,8 @@
"""
from __future__ import division, absolute_import, print_function
+from functools import reduce
+
import numpy as np
import numpy.polynomial.chebyshev as cheb
from numpy.polynomial.polynomial import polyval
@@ -111,6 +113,15 @@ class TestArithmetic(object):
res = cheb.chebadd(cheb.chebmul(quo, ci), rem)
assert_equal(trim(res), trim(tgt), err_msg=msg)
+ def test_chebpow(self):
+ for i in range(5):
+ for j in range(5):
+ msg = "At i=%d, j=%d" % (i, j)
+ c = np.arange(i + 1)
+ tgt = reduce(cheb.chebmul, [c]*j, np.array([1]))
+ res = cheb.chebpow(c, j)
+ assert_equal(trim(res), trim(tgt), err_msg=msg)
+
class TestEvaluation(object):
# coefficients of 1 + 2*x + 3*x**2
diff --git a/numpy/polynomial/tests/test_hermite.py b/numpy/polynomial/tests/test_hermite.py
index 18c26af8f..1287ef3fe 100644
--- a/numpy/polynomial/tests/test_hermite.py
+++ b/numpy/polynomial/tests/test_hermite.py
@@ -3,6 +3,8 @@
"""
from __future__ import division, absolute_import, print_function
+from functools import reduce
+
import numpy as np
import numpy.polynomial.hermite as herm
from numpy.polynomial.polynomial import polyval
@@ -99,6 +101,15 @@ class TestArithmetic(object):
res = herm.hermadd(herm.hermmul(quo, ci), rem)
assert_equal(trim(res), trim(tgt), err_msg=msg)
+ def test_hermpow(self):
+ for i in range(5):
+ for j in range(5):
+ msg = "At i=%d, j=%d" % (i, j)
+ c = np.arange(i + 1)
+ tgt = reduce(herm.hermmul, [c]*j, np.array([1]))
+ res = herm.hermpow(c, j)
+ assert_equal(trim(res), trim(tgt), err_msg=msg)
+
class TestEvaluation(object):
# coefficients of 1 + 2*x + 3*x**2
diff --git a/numpy/polynomial/tests/test_hermite_e.py b/numpy/polynomial/tests/test_hermite_e.py
index 58d74dae9..ccb44ad73 100644
--- a/numpy/polynomial/tests/test_hermite_e.py
+++ b/numpy/polynomial/tests/test_hermite_e.py
@@ -3,6 +3,8 @@
"""
from __future__ import division, absolute_import, print_function
+from functools import reduce
+
import numpy as np
import numpy.polynomial.hermite_e as herme
from numpy.polynomial.polynomial import polyval
@@ -99,6 +101,15 @@ class TestArithmetic(object):
res = herme.hermeadd(herme.hermemul(quo, ci), rem)
assert_equal(trim(res), trim(tgt), err_msg=msg)
+ def test_hermepow(self):
+ for i in range(5):
+ for j in range(5):
+ msg = "At i=%d, j=%d" % (i, j)
+ c = np.arange(i + 1)
+ tgt = reduce(herme.hermemul, [c]*j, np.array([1]))
+ res = herme.hermepow(c, j)
+ assert_equal(trim(res), trim(tgt), err_msg=msg)
+
class TestEvaluation(object):
# coefficients of 1 + 2*x + 3*x**2
diff --git a/numpy/polynomial/tests/test_laguerre.py b/numpy/polynomial/tests/test_laguerre.py
index 3cb630e46..3ababec5e 100644
--- a/numpy/polynomial/tests/test_laguerre.py
+++ b/numpy/polynomial/tests/test_laguerre.py
@@ -3,6 +3,8 @@
"""
from __future__ import division, absolute_import, print_function
+from functools import reduce
+
import numpy as np
import numpy.polynomial.laguerre as lag
from numpy.polynomial.polynomial import polyval
@@ -96,6 +98,15 @@ class TestArithmetic(object):
res = lag.lagadd(lag.lagmul(quo, ci), rem)
assert_almost_equal(trim(res), trim(tgt), err_msg=msg)
+ def test_lagpow(self):
+ for i in range(5):
+ for j in range(5):
+ msg = "At i=%d, j=%d" % (i, j)
+ c = np.arange(i + 1)
+ tgt = reduce(lag.lagmul, [c]*j, np.array([1]))
+ res = lag.lagpow(c, j)
+ assert_equal(trim(res), trim(tgt), err_msg=msg)
+
class TestEvaluation(object):
# coefficients of 1 + 2*x + 3*x**2
diff --git a/numpy/polynomial/tests/test_legendre.py b/numpy/polynomial/tests/test_legendre.py
index aeecd8775..a23086d59 100644
--- a/numpy/polynomial/tests/test_legendre.py
+++ b/numpy/polynomial/tests/test_legendre.py
@@ -3,6 +3,8 @@
"""
from __future__ import division, absolute_import, print_function
+from functools import reduce
+
import numpy as np
import numpy.polynomial.legendre as leg
from numpy.polynomial.polynomial import polyval
@@ -100,6 +102,15 @@ class TestArithmetic(object):
res = leg.legadd(leg.legmul(quo, ci), rem)
assert_equal(trim(res), trim(tgt), err_msg=msg)
+ def test_legpow(self):
+ for i in range(5):
+ for j in range(5):
+ msg = "At i=%d, j=%d" % (i, j)
+ c = np.arange(i + 1)
+ tgt = reduce(leg.legmul, [c]*j, np.array([1]))
+ res = leg.legpow(c, j)
+ assert_equal(trim(res), trim(tgt), err_msg=msg)
+
class TestEvaluation(object):
# coefficients of 1 + 2*x + 3*x**2
diff --git a/numpy/polynomial/tests/test_polynomial.py b/numpy/polynomial/tests/test_polynomial.py
index 67728e35e..0c93be278 100644
--- a/numpy/polynomial/tests/test_polynomial.py
+++ b/numpy/polynomial/tests/test_polynomial.py
@@ -3,6 +3,8 @@
"""
from __future__ import division, absolute_import, print_function
+from functools import reduce
+
import numpy as np
import numpy.polynomial.polynomial as poly
from numpy.testing import (
@@ -102,6 +104,15 @@ class TestArithmetic(object):
res = poly.polyadd(poly.polymul(quo, ci), rem)
assert_equal(res, tgt, err_msg=msg)
+ def test_polypow(self):
+ for i in range(5):
+ for j in range(5):
+ msg = "At i=%d, j=%d" % (i, j)
+ c = np.arange(i + 1)
+ tgt = reduce(poly.polymul, [c]*j, np.array([1]))
+ res = poly.polypow(c, j)
+ assert_equal(trim(res), trim(tgt), err_msg=msg)
+
class TestEvaluation(object):
# coefficients of 1 + 2*x + 3*x**2