summaryrefslogtreecommitdiff
path: root/numpy/polynomial/tests
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/polynomial/tests')
-rw-r--r--numpy/polynomial/tests/test_chebyshev.py61
-rw-r--r--numpy/polynomial/tests/test_classes.py306
-rw-r--r--numpy/polynomial/tests/test_hermite.py61
-rw-r--r--numpy/polynomial/tests/test_hermite_e.py61
-rw-r--r--numpy/polynomial/tests/test_laguerre.py61
-rw-r--r--numpy/polynomial/tests/test_legendre.py61
-rw-r--r--numpy/polynomial/tests/test_polynomial.py63
7 files changed, 245 insertions, 429 deletions
diff --git a/numpy/polynomial/tests/test_chebyshev.py b/numpy/polynomial/tests/test_chebyshev.py
index 95d241d94..16dd877fa 100644
--- a/numpy/polynomial/tests/test_chebyshev.py
+++ b/numpy/polynomial/tests/test_chebyshev.py
@@ -545,60 +545,6 @@ class TestChebyshevClass(TestCase) :
p4 = cheb.Chebyshev([2,2,3])
p5 = cheb.Chebyshev([3,2,3])
- def test_equal(self) :
- assert_(self.p1 == self.p1)
- assert_(self.p2 == self.p2)
- assert_(not self.p1 == self.p2)
- assert_(not self.p1 == self.p3)
- assert_(not self.p1 == [1,2,3])
-
- def test_not_equal(self) :
- assert_(not self.p1 != self.p1)
- assert_(not self.p2 != self.p2)
- assert_(self.p1 != self.p2)
- assert_(self.p1 != self.p3)
- assert_(self.p1 != [1,2,3])
-
- def test_add(self) :
- tgt = cheb.Chebyshev([2,4,6])
- assert_(self.p1 + self.p1 == tgt)
- assert_(self.p1 + [1,2,3] == tgt)
- assert_([1,2,3] + self.p1 == tgt)
-
- def test_sub(self) :
- tgt = cheb.Chebyshev([1])
- assert_(self.p4 - self.p1 == tgt)
- assert_(self.p4 - [1,2,3] == tgt)
- assert_([2,2,3] - self.p1 == tgt)
-
- def test_mul(self) :
- tgt = cheb.Chebyshev([7.5, 10., 8., 6., 4.5])
- assert_(self.p1 * self.p1 == tgt)
- assert_(self.p1 * [1,2,3] == tgt)
- assert_([1,2,3] * self.p1 == tgt)
-
- def test_floordiv(self) :
- tgt = cheb.Chebyshev([1])
- assert_(self.p4 // self.p1 == tgt)
- assert_(self.p4 // [1,2,3] == tgt)
- assert_([2,2,3] // self.p1 == tgt)
-
- def test_mod(self) :
- tgt = cheb.Chebyshev([1])
- assert_((self.p4 % self.p1) == tgt)
- assert_((self.p4 % [1,2,3]) == tgt)
- assert_(([2,2,3] % self.p1) == tgt)
-
- def test_divmod(self) :
- tquo = cheb.Chebyshev([1])
- trem = cheb.Chebyshev([2])
- quo, rem = divmod(self.p5, self.p1)
- assert_(quo == tquo and rem == trem)
- quo, rem = divmod(self.p5, [1,2,3])
- assert_(quo == tquo and rem == trem)
- quo, rem = divmod([3,2,3], self.p1)
- assert_(quo == tquo and rem == trem)
-
def test_pow(self) :
tgt = cheb.Chebyshev([1])
for i in range(5) :
@@ -654,13 +600,6 @@ class TestChebyshevClass(TestCase) :
p = self.p2.integ(2, [1, 2])
assert_almost_equal(p.coef, cheb.chebint([1,2,3], 2, [1,2], scl=.5))
- def test_identity(self) :
- x = np.linspace(0,3)
- p = cheb.Chebyshev.identity()
- assert_almost_equal(p(x), x)
- p = cheb.Chebyshev.identity([1,3])
- assert_almost_equal(p(x), x)
-
if __name__ == "__main__":
run_module_suite()
diff --git a/numpy/polynomial/tests/test_classes.py b/numpy/polynomial/tests/test_classes.py
index e0fc28f33..5fb096e94 100644
--- a/numpy/polynomial/tests/test_classes.py
+++ b/numpy/polynomial/tests/test_classes.py
@@ -17,6 +17,18 @@ classes = (
Polynomial, Legendre, Chebyshev, Laguerre,
Hermite, HermiteE)
+random = np.random.random
+
+def assert_poly_almost_equal(p1, p2, msg):
+ try:
+ assert_(np.all(p1.domain == p2.domain))
+ assert_(np.all(p1.window == p2.window))
+ assert_almost_equal(p1.coef, p2.coef)
+ except AssertionError:
+ msg = "Result: %s\nTarget: %s", (p1, p2)
+ raise AssertionError(msg)
+
+
class TestClassConversions(TestCase):
def test_conversion(self):
@@ -24,14 +36,14 @@ class TestClassConversions(TestCase):
window = np.array([0, 1])
domain = np.array([0, 1])
for Poly1 in classes:
- d1 = domain + np.random.random((2,))*.25
- w1 = window + np.random.random((2,))*.25
- c1 = np.random.random((3,))
+ d1 = domain + random((2,))*.25
+ w1 = window + random((2,))*.25
+ c1 = random((3,))
p1 = Poly1(c1, domain=d1, window=w1)
for Poly2 in classes:
msg = "-- %s -> %s" % (Poly1.__name__, Poly2.__name__)
- d2 = domain + np.random.random((2,))*.25
- w2 = window + np.random.random((2,))*.25
+ d2 = domain + random((2,))*.25
+ w2 = window + random((2,))*.25
p2 = p1.convert(kind=Poly2, domain=d2, window=w2)
assert_almost_equal(p2.domain, d2, err_msg=msg)
assert_almost_equal(p2.window, w2, err_msg=msg)
@@ -42,14 +54,14 @@ class TestClassConversions(TestCase):
window = np.array([0, 1])
domain = np.array([0, 1])
for Poly1 in classes:
- d1 = domain + np.random.random((2,))*.25
- w1 = window + np.random.random((2,))*.25
- c1 = np.random.random((3,))
+ d1 = domain + random((2,))*.25
+ w1 = window + random((2,))*.25
+ c1 = random((3,))
p1 = Poly1(c1, domain=d1, window=w1)
for Poly2 in classes:
msg = "-- %s -> %s" % (Poly1.__name__, Poly2.__name__)
- d2 = domain + np.random.random((2,))*.25
- w2 = window + np.random.random((2,))*.25
+ d2 = domain + random((2,))*.25
+ w2 = window + random((2,))*.25
p2 = Poly2.cast(p1, domain=d2, window=w2)
assert_almost_equal(p2.domain, d2, err_msg=msg)
assert_almost_equal(p2.window, w2, err_msg=msg)
@@ -58,13 +70,28 @@ class TestClassConversions(TestCase):
class TestClasses(TestCase):
+ # Static class methods
+
+ def test_identity(self) :
+ window = np.array([0, 1])
+ domain = np.array([0, 1])
+ x = np.linspace(0, 1, 11)
+ for Poly in classes:
+ msg = "-- %s" % (Poly.__name__,)
+ d = domain + random((2,))*.25
+ w = window + random((2,))*.25
+ p = Poly.identity(domain=d, window=w)
+ assert_equal(p.domain, d, err_msg=msg)
+ assert_equal(p.window, w, err_msg=msg)
+ assert_almost_equal(p(x), x, err_msg=msg)
+
def test_basis(self):
window = np.array([0, 1])
domain = np.array([0, 1])
for Poly in classes:
msg = "-- %s" % (Poly.__name__,)
- d = domain + np.random.random((2,))*.25
- w = window + np.random.random((2,))*.25
+ d = domain + random((2,))*.25
+ w = window + random((2,))*.25
p = Poly.basis(5, domain=d, window=w)
assert_equal(p.domain, d, err_msg=msg)
assert_equal(p.window, w, err_msg=msg)
@@ -75,25 +102,220 @@ class TestClasses(TestCase):
domain = np.array([0, 1])
for Poly in classes:
msg = "-- %s" % (Poly.__name__,)
- d = domain + np.random.random((2,))*.25
- w = window + np.random.random((2,))*.25
- r = np.random.random((5,))
+
+ # test that requested roots are zeros of a polynomial
+ # of correct degree, domain, and window.
+ d = domain + random((2,))*.25
+ w = window + random((2,))*.25
+ r = random((5,))
p1 = Poly.fromroots(r, domain=d, window=w)
+ assert_equal(p1.degree(), len(r), err_msg=msg)
assert_equal(p1.domain, d, err_msg=msg)
assert_equal(p1.window, w, err_msg=msg)
assert_almost_equal(p1(r), 0, err_msg=msg)
- # test monic with same domain and window
+
+ # check that polynomial is monic
p2 = Polynomial.cast(p1, domain=d, window=w)
assert_almost_equal(p2.coef[-1], 1, err_msg=msg)
+ def test_fit(self) :
+
+ def f(x) :
+ return x*(x - 1)*(x - 2)
+ x = np.linspace(0,3)
+ y = f(x)
+
+ window = np.array([0, 1])
+ domain = np.array([0, 1])
+ for Poly in classes:
+ msg = "-- %s" % (Poly.__name__,)
+
+ # test default value of domain
+ p = Poly.fit(x, y, 3)
+ assert_almost_equal(p.domain, [0,3], err_msg=msg)
+ assert_almost_equal(p(x), y, err_msg=msg)
+ assert_equal(p.degree(), 3, err_msg=msg)
+
+ # test with given windows and domains
+ d = domain + random((2,))*.25
+ w = window + random((2,))*.25
+ p = Poly.fit(x, y, 3, domain=d, window=w)
+ assert_almost_equal(p(x), y, err_msg=msg)
+ assert_almost_equal(p.domain, d, err_msg=msg)
+ assert_almost_equal(p.window, w, err_msg=msg)
+
+ # test with class domain default
+ p = Poly.fit(x, y, 3, [])
+ assert_equal(p.domain, Poly.domain, err_msg=msg)
+ assert_equal(p.window, Poly.window, err_msg=msg)
+
+ # test that fit accepts weights.
+ w = np.zeros_like(x)
+ z = y + random(y.shape)*.25
+ w[::2] = 1
+ p1 = Poly.fit(x[::2], z[::2], 3)
+ p2 = Poly.fit(x, z, 3, w=w)
+ assert_almost_equal(p1(x), p2(x), err_msg=msg)
+
+ # Instance class methods
+
+ def test_equal(self) :
+ for Poly in classes:
+ msg = "-- %s" % (Poly.__name__,)
+ p1 = Poly([1, 2, 3], domain=[0, 1], window=[2, 3])
+ p2 = Poly([1, 1, 1], domain=[0, 1], window=[2, 3])
+ p3 = Poly([1, 2, 3], domain=[1, 2], window=[2, 3])
+ p4 = Poly([1, 2, 3], domain=[0, 1], window=[1, 2])
+ assert_(p1 == p1, msg)
+ assert_(not p1 == p2, msg)
+ assert_(not p1 == p3, msg)
+ assert_(not p1 == p4, msg)
+
+ def test_not_equal(self) :
+ for Poly in classes:
+ msg = "-- %s" % (Poly.__name__,)
+ p1 = Poly([1, 2, 3], domain=[0, 1], window=[2, 3])
+ p2 = Poly([1, 1, 1], domain=[0, 1], window=[2, 3])
+ p3 = Poly([1, 2, 3], domain=[1, 2], window=[2, 3])
+ p4 = Poly([1, 2, 3], domain=[0, 1], window=[1, 2])
+ assert_(not p1 != p1, msg)
+ assert_(p1 != p2, msg)
+ assert_(p1 != p3, msg)
+ assert_(p1 != p4, msg)
+
+ def test_add(self) :
+ # This checks commutation, not numerical correctness
+ for Poly in classes:
+ msg = "-- %s" % (Poly.__name__,)
+ c1 = list(random((4,)) + .5)
+ c2 = list(random((3,)) + .5)
+ p1 = Poly(c1)
+ p2 = Poly(c2)
+ p3 = p1 + p2
+ assert_poly_almost_equal(p2 + p1, p3, msg)
+ assert_poly_almost_equal(p1 + c2, p3, msg)
+ assert_poly_almost_equal(c2 + p1, p3, msg)
+ assert_poly_almost_equal(p1 + tuple(c2), p3, msg)
+ assert_poly_almost_equal(tuple(c2) + p1, p3, msg)
+ assert_poly_almost_equal(p1 + np.array(c2), p3, msg)
+ assert_poly_almost_equal(np.array(c2) + p1, p3, msg)
+
+ def test_sub(self) :
+ # This checks commutation, not numerical correctness
+ for Poly in classes:
+ msg = "-- %s" % (Poly.__name__,)
+ c1 = list(random((4,)) + .5)
+ c2 = list(random((3,)) + .5)
+ p1 = Poly(c1)
+ p2 = Poly(c2)
+ p3 = p1 - p2
+ assert_poly_almost_equal(p2 - p1, -p3, msg)
+ assert_poly_almost_equal(p1 - c2, p3, msg)
+ assert_poly_almost_equal(c2 - p1, -p3, msg)
+ assert_poly_almost_equal(p1 - tuple(c2), p3, msg)
+ assert_poly_almost_equal(tuple(c2) - p1, -p3, msg)
+ assert_poly_almost_equal(p1 - np.array(c2), p3, msg)
+ assert_poly_almost_equal(np.array(c2) - p1, -p3, msg)
+
+ def test_mul(self) :
+ # This checks commutation, not numerical correctness
+ for Poly in classes:
+ msg = "-- %s" % (Poly.__name__,)
+ c1 = list(random((4,)) + .5)
+ c2 = list(random((3,)) + .5)
+ p1 = Poly(c1)
+ p2 = Poly(c2)
+ p3 = p1 * p2
+ assert_poly_almost_equal(p2 * p1, p3, msg)
+ assert_poly_almost_equal(p1 * c2, p3, msg)
+ assert_poly_almost_equal(c2 * p1, p3, msg)
+ assert_poly_almost_equal(p1 * tuple(c2), p3, msg)
+ assert_poly_almost_equal(tuple(c2) * p1, p3, msg)
+ assert_poly_almost_equal(p1 * np.array(c2), p3, msg)
+ assert_poly_almost_equal(np.array(c2) * p1, p3, msg)
+
+ def test_floordiv(self) :
+ # This checks commutation, not numerical correctness
+ for Poly in classes:
+ msg = "-- %s" % (Poly.__name__,)
+ c1 = list(random((4,)) + .5)
+ c2 = list(random((3,)) + .5)
+ c3 = list(random((2,)) + .5)
+ p1 = Poly(c1)
+ p2 = Poly(c2)
+ p3 = Poly(c3)
+ p4 = p1 * p2 + p3
+ c4 = list(p4.coef)
+ assert_poly_almost_equal(p4 // p2, p1, msg)
+ assert_poly_almost_equal(p4 // c2, p1, msg)
+ assert_poly_almost_equal(c4 // p2, p1, msg)
+ assert_poly_almost_equal(p4 // tuple(c2), p1, msg)
+ assert_poly_almost_equal(tuple(c4) // p2, p1, msg)
+ assert_poly_almost_equal(p4 // np.array(c2), p1, msg)
+ assert_poly_almost_equal(np.array(c4) // p2, p1, msg)
+
+ def test_mod(self) :
+ # This checks commutation, not numerical correctness
+ for Poly in classes:
+ msg = "-- %s" % (Poly.__name__,)
+ c1 = list(random((4,)) + .5)
+ c2 = list(random((3,)) + .5)
+ c3 = list(random((2,)) + .5)
+ p1 = Poly(c1)
+ p2 = Poly(c2)
+ p3 = Poly(c3)
+ p4 = p1 * p2 + p3
+ c4 = list(p4.coef)
+ assert_poly_almost_equal(p4 % p2, p3, msg)
+ assert_poly_almost_equal(p4 % c2, p3, msg)
+ assert_poly_almost_equal(c4 % p2, p3, msg)
+ assert_poly_almost_equal(p4 % tuple(c2), p3, msg)
+ assert_poly_almost_equal(tuple(c4) % p2, p3, msg)
+ assert_poly_almost_equal(p4 % np.array(c2), p3, msg)
+ assert_poly_almost_equal(np.array(c4) % p2, p3, msg)
+
+ def test_divmod(self) :
+ # This checks commutation, not numerical correctness
+ for Poly in classes:
+ msg = "-- %s" % (Poly.__name__,)
+ c1 = list(random((4,)) + .5)
+ c2 = list(random((3,)) + .5)
+ c3 = list(random((2,)) + .5)
+ p1 = Poly(c1)
+ p2 = Poly(c2)
+ p3 = Poly(c3)
+ p4 = p1 * p2 + p3
+ c4 = list(p4.coef)
+ quo, rem = divmod(p4, p2)
+ assert_poly_almost_equal(quo, p1, msg)
+ assert_poly_almost_equal(rem, p3, msg)
+ quo, rem = divmod(p4, c2)
+ assert_poly_almost_equal(quo, p1, msg)
+ assert_poly_almost_equal(rem, p3, msg)
+ quo, rem = divmod(c4, p2)
+ assert_poly_almost_equal(quo, p1, msg)
+ assert_poly_almost_equal(rem, p3, msg)
+ quo, rem = divmod(p4, tuple(c2))
+ assert_poly_almost_equal(quo, p1, msg)
+ assert_poly_almost_equal(rem, p3, msg)
+ quo, rem = divmod(tuple(c4), p2)
+ assert_poly_almost_equal(quo, p1, msg)
+ assert_poly_almost_equal(rem, p3, msg)
+ quo, rem = divmod(p4, np.array(c2))
+ assert_poly_almost_equal(quo, p1, msg)
+ assert_poly_almost_equal(rem, p3, msg)
+ quo, rem = divmod(np.array(c4), p2)
+ assert_poly_almost_equal(quo, p1, msg)
+ assert_poly_almost_equal(rem, p3, msg)
+
def test_roots(self):
window = np.array([0, 1])
domain = np.array([0, 1])
for Poly in classes:
msg = "-- %s" % (Poly.__name__,)
- d = domain + np.random.random((2,))*.25
- w = window + np.random.random((2,))*.25
- tgt = np.sort(np.random.random((5,)))
+ d = domain + random((2,))*.25
+ w = window + random((2,))*.25
+ tgt = np.sort(random((5,)))
res = np.sort(Poly.fromroots(tgt).roots())
assert_almost_equal(res, tgt, err_msg=msg)
@@ -121,8 +343,8 @@ class TestClasses(TestCase):
domain = np.array([0, 1])
for Poly in classes:
msg = "-- %s" % (Poly.__name__,)
- d = domain + np.random.random((2,))*.25
- w = window + np.random.random((2,))*.25
+ d = domain + random((2,))*.25
+ w = window + random((2,))*.25
p1 = Poly([1, 2, 3], domain=d, window=w)
p2 = p1.integ(2, k=[1, 2])
p3 = p1.integ(1, k=[1])
@@ -134,8 +356,8 @@ class TestClasses(TestCase):
domain = np.array([0, 1])
for Poly in classes:
msg = "-- %s" % (Poly.__name__,)
- d = domain + np.random.random((2,))*.25
- w = window + np.random.random((2,))*.25
+ d = domain + random((2,))*.25
+ w = window + random((2,))*.25
p = Poly([1,2,3], domain=d, window=w)
# test default domain
xtgt = np.linspace(d[0], d[1], 20)
@@ -150,44 +372,6 @@ class TestClasses(TestCase):
assert_almost_equal(xres, xtgt, err_msg=msg)
assert_almost_equal(yres, ytgt, err_msg=msg)
- def test_fit(self) :
-
- def f(x) :
- return x*(x - 1)*(x - 2)
- x = np.linspace(0,3)
- y = f(x)
-
- window = np.array([0, 1])
- domain = np.array([0, 1])
- for Poly in classes:
- msg = "-- %s" % (Poly.__name__,)
- # test default value of domain
- p = Poly.fit(x, y, 3)
- assert_almost_equal(p.domain, [0,3], err_msg=msg)
- assert_almost_equal(p(x), y, err_msg=msg)
- assert_equal(p.degree(), 3, err_msg=msg)
-
- # test with given windows and domains
- d = domain + np.random.random((2,))*.25
- w = window + np.random.random((2,))*.25
- p = Poly.fit(x, y, 3, domain=d, window=w)
- assert_almost_equal(p(x), y, err_msg=msg)
- assert_almost_equal(p.domain, d, err_msg=msg)
- assert_almost_equal(p.window, w, err_msg=msg)
-
- # test with class domain default
- p = Poly.fit(x, y, 3, [])
- assert_equal(p.domain, Poly.domain, err_msg=msg)
- assert_equal(p.window, Poly.window, err_msg=msg)
-
- # test that fit accepts weights.
- w = np.zeros_like(x)
- z = y + np.random.random(y.shape)*.25
- w[::2] = 1
- p1 = Poly.fit(x[::2], z[::2], 3)
- p2 = Poly.fit(x, z, 3, w=w)
- assert_almost_equal(p1(x), p2(x), err_msg=msg)
-
if __name__ == "__main__":
run_module_suite()
diff --git a/numpy/polynomial/tests/test_hermite.py b/numpy/polynomial/tests/test_hermite.py
index 8fe0da652..b0ccf8b64 100644
--- a/numpy/polynomial/tests/test_hermite.py
+++ b/numpy/polynomial/tests/test_hermite.py
@@ -510,60 +510,6 @@ class TestHermiteClass(TestCase) :
p4 = herm.Hermite([2,2,3])
p5 = herm.Hermite([3,2,3])
- def test_equal(self) :
- assert_(self.p1 == self.p1)
- assert_(self.p2 == self.p2)
- assert_(not self.p1 == self.p2)
- assert_(not self.p1 == self.p3)
- assert_(not self.p1 == [1,2,3])
-
- def test_not_equal(self) :
- assert_(not self.p1 != self.p1)
- assert_(not self.p2 != self.p2)
- assert_(self.p1 != self.p2)
- assert_(self.p1 != self.p3)
- assert_(self.p1 != [1,2,3])
-
- def test_add(self) :
- tgt = herm.Hermite([2,4,6])
- assert_(self.p1 + self.p1 == tgt)
- assert_(self.p1 + [1,2,3] == tgt)
- assert_([1,2,3] + self.p1 == tgt)
-
- def test_sub(self) :
- tgt = herm.Hermite([1])
- assert_(self.p4 - self.p1 == tgt)
- assert_(self.p4 - [1,2,3] == tgt)
- assert_([2,2,3] - self.p1 == tgt)
-
- def test_mul(self) :
- tgt = herm.Hermite([ 81., 52., 82., 12., 9.])
- assert_poly_almost_equal(self.p1 * self.p1, tgt)
- assert_poly_almost_equal(self.p1 * [1,2,3], tgt)
- assert_poly_almost_equal([1,2,3] * self.p1, tgt)
-
- def test_floordiv(self) :
- tgt = herm.Hermite([1])
- assert_(self.p4 // self.p1 == tgt)
- assert_(self.p4 // [1,2,3] == tgt)
- assert_([2,2,3] // self.p1 == tgt)
-
- def test_mod(self) :
- tgt = herm.Hermite([1])
- assert_((self.p4 % self.p1) == tgt)
- assert_((self.p4 % [1,2,3]) == tgt)
- assert_(([2,2,3] % self.p1) == tgt)
-
- def test_divmod(self) :
- tquo = herm.Hermite([1])
- trem = herm.Hermite([2])
- quo, rem = divmod(self.p5, self.p1)
- assert_(quo == tquo and rem == trem)
- quo, rem = divmod(self.p5, [1,2,3])
- assert_(quo == tquo and rem == trem)
- quo, rem = divmod([3,2,3], self.p1)
- assert_(quo == tquo and rem == trem)
-
def test_pow(self) :
tgt = herm.Hermite([1])
for i in range(5) :
@@ -619,13 +565,6 @@ class TestHermiteClass(TestCase) :
p = self.p2.integ(2, [1, 2])
assert_almost_equal(p.coef, herm.hermint([1,2,3], 2, [1,2], scl=.5))
- def test_identity(self) :
- x = np.linspace(0,3)
- p = herm.Hermite.identity()
- assert_almost_equal(p(x), x)
- p = herm.Hermite.identity([1,3])
- assert_almost_equal(p(x), x)
-
if __name__ == "__main__":
run_module_suite()
diff --git a/numpy/polynomial/tests/test_hermite_e.py b/numpy/polynomial/tests/test_hermite_e.py
index 552f21ae0..8a3047ee0 100644
--- a/numpy/polynomial/tests/test_hermite_e.py
+++ b/numpy/polynomial/tests/test_hermite_e.py
@@ -507,60 +507,6 @@ class TestHermiteEClass(TestCase) :
p4 = herme.HermiteE([2,2,3])
p5 = herme.HermiteE([3,2,3])
- def test_equal(self) :
- assert_(self.p1 == self.p1)
- assert_(self.p2 == self.p2)
- assert_(not self.p1 == self.p2)
- assert_(not self.p1 == self.p3)
- assert_(not self.p1 == [1,2,3])
-
- def test_not_equal(self) :
- assert_(not self.p1 != self.p1)
- assert_(not self.p2 != self.p2)
- assert_(self.p1 != self.p2)
- assert_(self.p1 != self.p3)
- assert_(self.p1 != [1,2,3])
-
- def test_add(self) :
- tgt = herme.HermiteE([2,4,6])
- assert_(self.p1 + self.p1 == tgt)
- assert_(self.p1 + [1,2,3] == tgt)
- assert_([1,2,3] + self.p1 == tgt)
-
- def test_sub(self) :
- tgt = herme.HermiteE([1])
- assert_(self.p4 - self.p1 == tgt)
- assert_(self.p4 - [1,2,3] == tgt)
- assert_([2,2,3] - self.p1 == tgt)
-
- def test_mul(self) :
- tgt = herme.HermiteE([ 23., 28., 46., 12., 9.])
- assert_poly_almost_equal(self.p1 * self.p1, tgt)
- assert_poly_almost_equal(self.p1 * [1,2,3], tgt)
- assert_poly_almost_equal([1,2,3] * self.p1, tgt)
-
- def test_floordiv(self) :
- tgt = herme.HermiteE([1])
- assert_(self.p4 // self.p1 == tgt)
- assert_(self.p4 // [1,2,3] == tgt)
- assert_([2,2,3] // self.p1 == tgt)
-
- def test_mod(self) :
- tgt = herme.HermiteE([1])
- assert_((self.p4 % self.p1) == tgt)
- assert_((self.p4 % [1,2,3]) == tgt)
- assert_(([2,2,3] % self.p1) == tgt)
-
- def test_divmod(self) :
- tquo = herme.HermiteE([1])
- trem = herme.HermiteE([2])
- quo, rem = divmod(self.p5, self.p1)
- assert_(quo == tquo and rem == trem)
- quo, rem = divmod(self.p5, [1,2,3])
- assert_(quo == tquo and rem == trem)
- quo, rem = divmod([3,2,3], self.p1)
- assert_(quo == tquo and rem == trem)
-
def test_pow(self) :
tgt = herme.HermiteE([1])
for i in range(5) :
@@ -616,13 +562,6 @@ class TestHermiteEClass(TestCase) :
p = self.p2.integ(2, [1, 2])
assert_almost_equal(p.coef, herme.hermeint([1,2,3], 2, [1,2], scl=.5))
- def test_identity(self) :
- x = np.linspace(0,3)
- p = herme.HermiteE.identity()
- assert_almost_equal(p(x), x)
- p = herme.HermiteE.identity([1,3])
- assert_almost_equal(p(x), x)
-
if __name__ == "__main__":
run_module_suite()
diff --git a/numpy/polynomial/tests/test_laguerre.py b/numpy/polynomial/tests/test_laguerre.py
index 0c411820e..d23724aca 100644
--- a/numpy/polynomial/tests/test_laguerre.py
+++ b/numpy/polynomial/tests/test_laguerre.py
@@ -505,60 +505,6 @@ class TestLaguerreClass(TestCase) :
p4 = lag.Laguerre([2,2,3])
p5 = lag.Laguerre([3,2,3])
- def test_equal(self) :
- assert_(self.p1 == self.p1)
- assert_(self.p2 == self.p2)
- assert_(not self.p1 == self.p2)
- assert_(not self.p1 == self.p3)
- assert_(not self.p1 == [1,2,3])
-
- def test_not_equal(self) :
- assert_(not self.p1 != self.p1)
- assert_(not self.p2 != self.p2)
- assert_(self.p1 != self.p2)
- assert_(self.p1 != self.p3)
- assert_(self.p1 != [1,2,3])
-
- def test_add(self) :
- tgt = lag.Laguerre([2,4,6])
- assert_(self.p1 + self.p1 == tgt)
- assert_(self.p1 + [1,2,3] == tgt)
- assert_([1,2,3] + self.p1 == tgt)
-
- def test_sub(self) :
- tgt = lag.Laguerre([1])
- assert_(self.p4 - self.p1 == tgt)
- assert_(self.p4 - [1,2,3] == tgt)
- assert_([2,2,3] - self.p1 == tgt)
-
- def test_mul(self) :
- tgt = lag.Laguerre([ 14., -16., 56., -72., 54.])
- assert_poly_almost_equal(self.p1 * self.p1, tgt)
- assert_poly_almost_equal(self.p1 * [1,2,3], tgt)
- assert_poly_almost_equal([1,2,3] * self.p1, tgt)
-
- def test_floordiv(self) :
- tgt = lag.Laguerre([1])
- assert_(self.p4 // self.p1 == tgt)
- assert_(self.p4 // [1,2,3] == tgt)
- assert_([2,2,3] // self.p1 == tgt)
-
- def test_mod(self) :
- tgt = lag.Laguerre([1])
- assert_((self.p4 % self.p1) == tgt)
- assert_((self.p4 % [1,2,3]) == tgt)
- assert_(([2,2,3] % self.p1) == tgt)
-
- def test_divmod(self) :
- tquo = lag.Laguerre([1])
- trem = lag.Laguerre([2])
- quo, rem = divmod(self.p5, self.p1)
- assert_(quo == tquo and rem == trem)
- quo, rem = divmod(self.p5, [1,2,3])
- assert_(quo == tquo and rem == trem)
- quo, rem = divmod([3,2,3], self.p1)
- assert_(quo == tquo and rem == trem)
-
def test_pow(self) :
tgt = lag.Laguerre([1])
for i in range(5) :
@@ -614,13 +560,6 @@ class TestLaguerreClass(TestCase) :
p = self.p2.integ(2, [1, 2])
assert_almost_equal(p.coef, lag.lagint([1,2,3], 2, [1,2], scl=.5))
- def test_identity(self) :
- x = np.linspace(0,3)
- p = lag.Laguerre.identity()
- assert_almost_equal(p(x), x)
- p = lag.Laguerre.identity([1,3])
- assert_almost_equal(p(x), x)
-
if __name__ == "__main__":
run_module_suite()
diff --git a/numpy/polynomial/tests/test_legendre.py b/numpy/polynomial/tests/test_legendre.py
index 4dc4f9a25..d4261a757 100644
--- a/numpy/polynomial/tests/test_legendre.py
+++ b/numpy/polynomial/tests/test_legendre.py
@@ -508,60 +508,6 @@ class TestLegendreClass(TestCase) :
p4 = leg.Legendre([2,2,3])
p5 = leg.Legendre([3,2,3])
- def test_equal(self) :
- assert_(self.p1 == self.p1)
- assert_(self.p2 == self.p2)
- assert_(not self.p1 == self.p2)
- assert_(not self.p1 == self.p3)
- assert_(not self.p1 == [1,2,3])
-
- def test_not_equal(self) :
- assert_(not self.p1 != self.p1)
- assert_(not self.p2 != self.p2)
- assert_(self.p1 != self.p2)
- assert_(self.p1 != self.p3)
- assert_(self.p1 != [1,2,3])
-
- def test_add(self) :
- tgt = leg.Legendre([2,4,6])
- assert_(self.p1 + self.p1 == tgt)
- assert_(self.p1 + [1,2,3] == tgt)
- assert_([1,2,3] + self.p1 == tgt)
-
- def test_sub(self) :
- tgt = leg.Legendre([1])
- assert_(self.p4 - self.p1 == tgt)
- assert_(self.p4 - [1,2,3] == tgt)
- assert_([2,2,3] - self.p1 == tgt)
-
- def test_mul(self) :
- tgt = leg.Legendre([4.13333333, 8.8, 11.23809524, 7.2, 4.62857143])
- assert_poly_almost_equal(self.p1 * self.p1, tgt)
- assert_poly_almost_equal(self.p1 * [1,2,3], tgt)
- assert_poly_almost_equal([1,2,3] * self.p1, tgt)
-
- def test_floordiv(self) :
- tgt = leg.Legendre([1])
- assert_(self.p4 // self.p1 == tgt)
- assert_(self.p4 // [1,2,3] == tgt)
- assert_([2,2,3] // self.p1 == tgt)
-
- def test_mod(self) :
- tgt = leg.Legendre([1])
- assert_((self.p4 % self.p1) == tgt)
- assert_((self.p4 % [1,2,3]) == tgt)
- assert_(([2,2,3] % self.p1) == tgt)
-
- def test_divmod(self) :
- tquo = leg.Legendre([1])
- trem = leg.Legendre([2])
- quo, rem = divmod(self.p5, self.p1)
- assert_(quo == tquo and rem == trem)
- quo, rem = divmod(self.p5, [1,2,3])
- assert_(quo == tquo and rem == trem)
- quo, rem = divmod([3,2,3], self.p1)
- assert_(quo == tquo and rem == trem)
-
def test_pow(self) :
tgt = leg.Legendre([1])
for i in range(5) :
@@ -617,13 +563,6 @@ 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_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()
diff --git a/numpy/polynomial/tests/test_polynomial.py b/numpy/polynomial/tests/test_polynomial.py
index 5715d8b2d..d016a27c4 100644
--- a/numpy/polynomial/tests/test_polynomial.py
+++ b/numpy/polynomial/tests/test_polynomial.py
@@ -463,60 +463,6 @@ class TestPolynomialClass(TestCase) :
p4 = poly.Polynomial([2,2,3])
p5 = poly.Polynomial([3,2,3])
- def test_equal(self) :
- assert_(self.p1 == self.p1)
- assert_(self.p2 == self.p2)
- assert_(not self.p1 == self.p2)
- assert_(not self.p1 == self.p3)
- assert_(not self.p1 == [1,2,3])
-
- def test_not_equal(self) :
- assert_(not self.p1 != self.p1)
- assert_(not self.p2 != self.p2)
- assert_(self.p1 != self.p2)
- assert_(self.p1 != self.p3)
- assert_(self.p1 != [1,2,3])
-
- def test_add(self) :
- tgt = poly.Polynomial([2,4,6])
- assert_(self.p1 + self.p1 == tgt)
- assert_(self.p1 + [1,2,3] == tgt)
- assert_([1,2,3] + self.p1 == tgt)
-
- def test_sub(self) :
- tgt = poly.Polynomial([1])
- assert_(self.p4 - self.p1 == tgt)
- assert_(self.p4 - [1,2,3] == tgt)
- assert_([2,2,3] - self.p1 == tgt)
-
- def test_mul(self) :
- tgt = poly.Polynomial([1,4,10,12,9])
- assert_(self.p1 * self.p1 == tgt)
- assert_(self.p1 * [1,2,3] == tgt)
- assert_([1,2,3] * self.p1 == tgt)
-
- def test_floordiv(self) :
- tgt = poly.Polynomial([1])
- assert_(self.p4 // self.p1 == tgt)
- assert_(self.p4 // [1,2,3] == tgt)
- assert_([2,2,3] // self.p1 == tgt)
-
- def test_mod(self) :
- tgt = poly.Polynomial([1])
- assert_((self.p4 % self.p1) == tgt)
- assert_((self.p4 % [1,2,3]) == tgt)
- assert_(([2,2,3] % self.p1) == tgt)
-
- def test_divmod(self) :
- tquo = poly.Polynomial([1])
- trem = poly.Polynomial([2])
- quo, rem = divmod(self.p5, self.p1)
- assert_(quo == tquo and rem == trem)
- quo, rem = divmod(self.p5, [1,2,3])
- assert_(quo == tquo and rem == trem)
- quo, rem = divmod([3,2,3], self.p1)
- assert_(quo == tquo and rem == trem)
-
def test_pow(self) :
tgt = poly.Polynomial([1])
for i in range(5) :
@@ -573,14 +519,5 @@ class TestPolynomialClass(TestCase) :
assert_almost_equal(p.coef, poly.polyint([1,2,3], 2, [1, 2], scl=.5))
- def test_identity(self) :
- x = np.linspace(0,3)
- p = poly.Polynomial.identity()
- assert_almost_equal(p(x), x)
- p = poly.Polynomial.identity([1,3])
- assert_almost_equal(p(x), x)
-
-
-
if __name__ == "__main__":
run_module_suite()