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

default time_M value in presence of saved TimeFunction is wrong #2235

Open
FabioLuporini opened this issue Oct 13, 2023 · 0 comments · May be fixed by #2237
Open

default time_M value in presence of saved TimeFunction is wrong #2235

FabioLuporini opened this issue Oct 13, 2023 · 0 comments · May be fixed by #2237
Labels

Comments

@FabioLuporini
Copy link
Contributor

Reproducer

import numpy as np
from devito import Eq, Grid, TimeFunction, Operator

grid = Grid(shape=(4, 4))

u = TimeFunction(name='u', grid=grid)
usave = TimeFunction(name='usave', grid=grid, save=5)

eqns = [Eq(u.forward, u + 1),
        Eq(usave, u)]

op = Operator(eqns)

assert op.arguments()['time_M'] == 4

op.apply()

assert all(np.all(usave.data[i] == i) for i in range(5))

The issue stems from the fact that op._dspace sets [0,1] as the time dimension's data space bounds, and that "1" will cause the default value to become 3. Which is clearly wrong, since 4 is perfectly fine here.

This violates the principle of least surprise.

@georgebisbas georgebisbas linked a pull request Oct 13, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant