devito
devito copied to clipboard
Operator with multiple objects with same names
Operator cannot handle multiple data carriers with same name.
For example
from devito import Grid, inner, Function
grid = Grid((10, 10))
u = Function(name="u", grid=grid)
u.data[:] = np.random.rand(*u.shape)
u1 = Function(name="u", grid=grid)
assert inner(u, u1) == 0 # Fails but is what it should be
assert inner(u, u1) == norm(u)**2 # Returns true (withing numerical prceision) as u1 is ignored because same name as u
Not sure how to handle it, probably automatically create aliases if there is multiple objects with the same name
I'm downgrading to bug-py-minor
from bug-py
how about we check the id
and the name
and raise SuitableException
if id
different but identical name
?
Not sure it should be an exception, IMO should be supported, in practice can happen fairly often, like a simple:
rec0 = solver.forward()
rec1 = solver.forward(vp=vp0)
inner(rec0, rec1)
then they have same name and not really a "nice" way to change the name of one of the two, and most people would expect this to work.