From c06f8b77933b3b18615875e67fa6bfe581ca8afe Mon Sep 17 00:00:00 2001
From: Stephan Seitz <stephan.seitz@fau.de>
Date: Fri, 2 Aug 2019 19:20:26 +0200
Subject: [PATCH] Implement Assignment.__hash__ for sympy <= 1.4

---
 pystencils/assignment.py | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/pystencils/assignment.py b/pystencils/assignment.py
index 45a95d41e..0bf687994 100644
--- a/pystencils/assignment.py
+++ b/pystencils/assignment.py
@@ -49,6 +49,17 @@ else:
         __str__ = assignment_str
         _print_Assignment = print_assignment_latex
 
+# Apparently, in SymPy 1.4 Assignment.__hash__ is not implemented. This has been fixed in current master
+try:
+    sympy_version = sp.__version__.split('.')
+
+    if int(sympy_version[0]) <= 1 and int(sympy_version[1]) <= 4:
+        def hash_fun(self):
+            return hash((self.lhs, self.rhs))
+        Assignment.__hash__ = hash_fun
+except Exception:
+    pass
+
 
 def assignment_from_stencil(stencil_array, input_field, output_field,
                             normalization_factor=None, order='visual') -> Assignment:
-- 
GitLab