X-Git-Url: https://svn.cri.ensmp.fr/git/linpy.git/blobdiff_plain/37b02d24c845fa3c75c48a99e5e658d772b72289..383296fc80db17317dd385821265003c01134f50:/pypol/linear.py?ds=sidebyside diff --git a/pypol/linear.py b/pypol/linear.py index bd7037b..2c71c02 100644 --- a/pypol/linear.py +++ b/pypol/linear.py @@ -62,7 +62,7 @@ class Expression: for symbol, coefficient in coefficients if coefficient != 0] if len(coefficients) == 0: return Constant(constant) - elif len(coefficients) == 1: + elif len(coefficients) == 1 and constant == 0: symbol, coefficient = coefficients[0] if coefficient == 1: return Symbol(symbol) @@ -271,7 +271,7 @@ class Expression: self.constant == other.constant def __hash__(self): - return hash((self._coefficients, self._constant)) + return hash((tuple(sorted(self._coefficients.items())), self._constant)) def _toint(self): lcm = functools.reduce(lambda a, b: a*b // gcd(a, b),