[Numpy-svn] r3894 - in trunk/numpy: core/tests lib

numpy-svn@scip... numpy-svn@scip...
Tue Jul 24 02:33:55 CDT 2007

```Author: stefan
Date: 2007-07-24 02:33:28 -0500 (Tue, 24 Jul 2007)
New Revision: 3894

Modified:
trunk/numpy/core/tests/test_regression.py
trunk/numpy/lib/polynomial.py
Log:
Fix polynomial comparison. Closes ticket #554.

Modified: trunk/numpy/core/tests/test_regression.py
===================================================================
--- trunk/numpy/core/tests/test_regression.py	2007-07-23 13:12:55 UTC (rev 3893)
+++ trunk/numpy/core/tests/test_regression.py	2007-07-24 07:33:28 UTC (rev 3894)
@@ -702,6 +702,13 @@
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()

Modified: trunk/numpy/lib/polynomial.py
===================================================================
--- trunk/numpy/lib/polynomial.py	2007-07-23 13:12:55 UTC (rev 3893)
+++ trunk/numpy/lib/polynomial.py	2007-07-24 07:33:28 UTC (rev 3894)
@@ -606,10 +606,10 @@
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."

```