devito icon indicating copy to clipboard operation
devito copied to clipboard

Substitution of DataSymbols is buggy when multiple symbols with the same name are present

Open EdCaunt opened this issue 1 year ago • 0 comments

MFE:

from devito.types.basic import DataSymbol
s0 = DataSymbol(name='s')
s1 = DataSymbol(name='s')

s2 = s0._rebuild(name='s2')
s3 = s1._rebuild(name='s3')

# Causes s1 to be incorrectly substituted
# mapper = {s0: s2, s1: s3}
# Causes s0 to be incorrectly substituted
mapper = {s1: s3, s0: s2}

print(s0.subs(mapper))
print(mapper[s0])

print(s1.subs(mapper))
print(mapper[s1])

Returns

s3
s2
s3
s3

rather than

s2
s2
s3
s3

This line is a potential culprit for this behaviour. #2510 features a workaround in the context of concretisation.

EdCaunt avatar Jan 07 '25 09:01 EdCaunt