Fix Expression.__bool__
[linpy.git] / pypol / linear.py
index 8f73fd3..749f7c3 100644 (file)
@@ -135,7 +135,7 @@ class Expression:
         return False
 
     def __bool__(self):
-        True
+        return True
 
     def __pos__(self):
         return self
@@ -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),