diff options
author | Sebastian Berg <sebastian@sipsolutions.net> | 2013-07-25 16:10:54 +0200 |
---|---|---|
committer | Sebastian Berg <sebastian@sipsolutions.net> | 2014-05-04 18:14:11 +0200 |
commit | 9b8f6c72caea0c6f3fa08b304135239636e4f165 (patch) | |
tree | b3418650ed740be1bb369f5ab2979749d4d27919 /numpy/lib/polynomial.py | |
parent | 84831ca7b7926bf1c73e1702201e7591c55588a3 (diff) | |
download | numpy-9b8f6c72caea0c6f3fa08b304135239636e4f165.tar.gz |
DEP: Deprecate that comparisons ignore errors.
This means that for example broadcasting errors get raised.
The array_equiv function is changed to explicitely test
if broadcasting is possible. It may be nice to do this
test differently, but I am not sure if that is possible.
Create a FutureWarning for comparisons to None, which
should result in areal elementwise (object) comparisons.
Slightly adepted a wrong test.
Poly changes: Some changes in the polycode was necessary,
the one is probably a bug fix, the other needs to be
thought over, since len check is not perfect maybe, since
it is more liekly to raise raise an error.
Closes gh-3759 and gh-1608
Diffstat (limited to 'numpy/lib/polynomial.py')
-rw-r--r-- | numpy/lib/polynomial.py | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/numpy/lib/polynomial.py b/numpy/lib/polynomial.py index 0dcb85bb2..e85e957e0 100644 --- a/numpy/lib/polynomial.py +++ b/numpy/lib/polynomial.py @@ -1193,10 +1193,24 @@ class poly1d(object): __rtruediv__ = __rdiv__ def __eq__(self, other): - return NX.alltrue(self.coeffs == other.coeffs) + dim = min(self.coeffs.shape[0], other.coeffs.shape[0]) + if (self.coeffs[-dim:] != other.coeffs[-dim:]).any(): + return False + elif (self.coeffs[:-dim] != 0).any(): + return False + elif (other.coeffs[:-dim] != 0).any(): + return False + return True def __ne__(self, other): - return NX.any(self.coeffs != other.coeffs) + dim = min(self.coeffs.shape[0], other.coeffs.shape[0]) + if (self.coeffs[-dim:] != other.coeffs[-dim:]).any(): + return True + elif (self.coeffs[:-dim] != 0).any(): + return True + elif (other.coeffs[:-dim] != 0).any(): + return True + return False def __setattr__(self, key, val): raise ValueError("Attributes cannot be changed this way.") |