Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compiler: Fix issue #2235 #2237

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Next Next commit
tests: enhance indirection testing
  • Loading branch information
georgebisbas committed Nov 20, 2024
commit d1b1e69e1cd3c69b06ca4bd7fa6780bbae637c01
21 changes: 12 additions & 9 deletions tests/test_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -1990,16 +1990,19 @@ def test_2194_v2(self, eqns, expected, exp_trees, exp_iters):

class TestInternals:

def test_indirection(self):
nt = 10
@pytest.mark.parametrize('nt, offset, epass',
([1, 1, True], [1, 2, False],
[5, 1, True], [3, 5, False],
[4, 1, True], [5, 10, False]))
def test_indirection(self, nt, offset, epass):
grid = Grid(shape=(4, 4))
time = grid.time_dim
x, y = grid.dimensions

f = TimeFunction(name='f', grid=grid, save=nt)
g = TimeFunction(name='g', grid=grid)

idx = time + 1
idx = time + offset
s = Indirection(name='ofs0', mapped=idx)

eqns = [
Expand All @@ -2010,10 +2013,10 @@ def test_indirection(self):
op = Operator(eqns)

assert op._dspace[time].lower == 0
assert op._dspace[time].upper == 1
assert op.arguments()['time_M'] == nt - 2
assert op._dspace[time].upper == offset

op()

assert np.all(f.data[0] == 0.)
assert np.all(f.data[i] == 3. for i in range(1, 10))
if epass:
assert op.arguments()['time_M'] == nt - offset - 1
op()
assert np.all(f.data[0] == 0.)
assert np.all(f.data[i] == 3. for i in range(1, nt))