devito icon indicating copy to clipboard operation
devito copied to clipboard

Operator with multiple objects with same names

Open mloubout opened this issue 4 years ago • 3 comments

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

mloubout avatar May 22 '20 14:05 mloubout

I'm downgrading to bug-py-minor from bug-py

FabioLuporini avatar May 23 '20 09:05 FabioLuporini

how about we check the id and the name and raise SuitableException if id different but identical name?

FabioLuporini avatar May 23 '20 09:05 FabioLuporini

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.

mloubout avatar May 23 '20 13:05 mloubout