X-Git-Url: https://svn.cri.ensmp.fr/git/linpy.git/blobdiff_plain/288355579f9b2160e341e1d48910a66a0124ab04..4a4d773df0dea3cea63023b8d01f380a0024e25a:/pypol/linear.py?ds=sidebyside diff --git a/pypol/linear.py b/pypol/linear.py index 8f73fd3..845fac3 100644 --- a/pypol/linear.py +++ b/pypol/linear.py @@ -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), @@ -355,7 +355,7 @@ class Symbol(Expression): def symbols(names): if isinstance(names, str): names = names.replace(',', ' ').split() - return (symbol(name) for name in names) + return (Symbol(name) for name in names) @_polymorphic_operator