From 5db80bb7ecdf2e30594de340786e92f3a0acf836 Mon Sep 17 00:00:00 2001 From: Alexander Reinauer <areinauer@icp.uni-stuttgart.de> Date: Tue, 16 Apr 2024 12:24:42 +0200 Subject: [PATCH] Fix new_merged for AssignmentCollections by first substituting the rhs with newly introduced symbols before comparing the rhs --- src/pystencils/simp/assignment_collection.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/pystencils/simp/assignment_collection.py b/src/pystencils/simp/assignment_collection.py index b0c09cec..40a5e4cc 100644 --- a/src/pystencils/simp/assignment_collection.py +++ b/src/pystencils/simp/assignment_collection.py @@ -286,12 +286,13 @@ class AssignmentCollection: processed_other_subexpression_equations = [] for other_subexpression_eq in other.subexpressions: if other_subexpression_eq.lhs in own_subexpression_symbols: - if other_subexpression_eq.rhs == own_subexpression_symbols[other_subexpression_eq.lhs]: + new_rhs = fast_subs(other_subexpression_eq.rhs, substitution_dict) + if new_rhs == own_subexpression_symbols[other_subexpression_eq.lhs]: continue # exact the same subexpression equation exists already else: # different definition - a new name has to be introduced new_lhs = next(self.subexpression_symbol_generator) - new_eq = Assignment(new_lhs, fast_subs(other_subexpression_eq.rhs, substitution_dict)) + new_eq = Assignment(new_lhs, new_rhs) processed_other_subexpression_equations.append(new_eq) substitution_dict[other_subexpression_eq.lhs] = new_lhs else: -- GitLab