Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

BUG: Set __hash__ = None for non-hashable classes.

Because neither poly1d nor the Polynomial package polynomial classes are
immutable, hence not reliably hashable, they should signal that by
setting __hash__ = None. This also fixes the warning

Overriding __eq__ blocks inheritance of __hash__ in 3.x

that is given when the command `python2.7 -3 -c"import numpy"` is run.
  • Loading branch information...
commit e2675e3ac08f2fb3a7e606123ad063e7e956cb9d 1 parent bec793a
@charris charris authored
Showing with 4 additions and 0 deletions.
  1. +2 −0  numpy/lib/polynomial.py
  2. +2 −0  numpy/polynomial/polytemplate.py
View
2  numpy/lib/polynomial.py
@@ -1030,6 +1030,8 @@ class poly1d(object):
coeffs = None
order = None
variable = None
+ __hash__ = None
+
def __init__(self, c_or_r, r=0, variable=None):
if isinstance(c_or_r, poly1d):
for key in c_or_r.__dict__.keys():
View
2  numpy/polynomial/polytemplate.py
@@ -79,6 +79,8 @@ class $name(pu.PolyBase) :
window = np.array($domain)
# Don't let participate in array operations. Value doesn't matter.
__array_priority__ = 1000
+ # Not hashable
+ __hash__ = None
def has_samecoef(self, other):
"""Check if coefficients match.
Please sign in to comment.
Something went wrong with that request. Please try again.