From d59f864456769673f3dea00003c7ad14ec73548c Mon Sep 17 00:00:00 2001 From: Stephan Seitz <stephan.seitz@fau.de> Date: Wed, 5 Feb 2020 12:42:01 +0100 Subject: [PATCH] Implement __hash__ for SympyAssignment --- pystencils/astnodes.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pystencils/astnodes.py b/pystencils/astnodes.py index 8ec80917a..498bbeec0 100644 --- a/pystencils/astnodes.py +++ b/pystencils/astnodes.py @@ -538,7 +538,7 @@ class LoopOverCoordinate(Node): class SympyAssignment(Node): def __init__(self, lhs_symbol, rhs_expr, is_const=True, use_auto=False): super(SympyAssignment, self).__init__(parent=None) - self._lhs_symbol = lhs_symbol + self._lhs_symbol = sp.sympify(lhs_symbol) self.rhs = sp.sympify(rhs_expr) self._is_const = is_const self._is_declaration = self.__is_declaration() @@ -621,6 +621,12 @@ class SympyAssignment(Node): printed_rhs = sp.latex(self.rhs) return "${printed_lhs} \\leftarrow {printed_rhs}$".format(printed_lhs=printed_lhs, printed_rhs=printed_rhs) + def __hash__(self): + return hash((self.lhs, self.rhs)) + + def __eq__(self, other): + return type(self) == type(other) and (self.lhs, self.rhs) == (other.lhs, other.rhs) + class ResolvedFieldAccess(sp.Indexed): def __new__(cls, base, linearized_index, field, offsets, idx_coordinate_values): -- GitLab