diff options
author | Stefan van der Walt <stefan@sun.ac.za> | 2007-07-24 07:33:28 +0000 |
---|---|---|
committer | Stefan van der Walt <stefan@sun.ac.za> | 2007-07-24 07:33:28 +0000 |
commit | 393473fbace1bb64ef73ab3ebd11a78db832dca1 (patch) | |
tree | 7a32a525b518f1c21ece4ebaef57cf975160094c | |
parent | 134e4bbaa54ff7938160b8e912a06af8f63bd513 (diff) | |
download | numpy-393473fbace1bb64ef73ab3ebd11a78db832dca1.tar.gz |
Fix polynomial comparison. Closes ticket #554.
-rw-r--r-- | numpy/core/tests/test_regression.py | 7 | ||||
-rw-r--r-- | numpy/lib/polynomial.py | 4 |
2 files changed, 9 insertions, 2 deletions
diff --git a/numpy/core/tests/test_regression.py b/numpy/core/tests/test_regression.py index e5fb33a73..88187e35a 100644 --- a/numpy/core/tests/test_regression.py +++ b/numpy/core/tests/test_regression.py @@ -702,6 +702,13 @@ class test_regression(NumpyTestCase): from numpy.oldnumeric.random_array import randint randint(0,50,[2,3]) + def check_poly_eq(self, level=rlevel): + """Ticket #554""" + x = N.poly1d([1,2,3]) + y = N.poly1d([3,4]) + assert x != y + assert x == x + if __name__ == "__main__": NumpyTest().run() diff --git a/numpy/lib/polynomial.py b/numpy/lib/polynomial.py index edaa319cd..8231cbd87 100644 --- a/numpy/lib/polynomial.py +++ b/numpy/lib/polynomial.py @@ -606,10 +606,10 @@ class poly1d(object): return polydiv(other, self) def __eq__(self, other): - return (self.coeffs == other.coeffs).all() + return NX.alltrue(self.coeffs == other.coeffs) def __ne__(self, other): - return (self.coeffs != other.coeffs).any() + return NX.any(self.coeffs != other.coeffs) def __setattr__(self, key, val): raise ValueError, "Attributes cannot be changed this way." |