Skip to content

Commit

Permalink
Expression: Better way to "clone" non-typed symbols in mapper
Browse files Browse the repository at this point in the history
  • Loading branch information
mlange05 committed Oct 31, 2024
1 parent 6ebcd89 commit 7f0c0ed
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion loki/expression/mappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,10 @@ def _rebuild(expr):
""" Utility to safely rebuild any symbol """
if hasattr(expr, 'clone'):
return expr.clone()
return deepcopy(expr)

# Re-create symbol Pymbolic-style
cargs = dict(zip(expr.init_arg_names, expr.__getinitargs__()))
return type(expr)(**cargs)

def __call__(self, expr, *args, **kwargs):
if expr is None:
Expand Down

0 comments on commit 7f0c0ed

Please sign in to comment.