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 arg processing for empty arg update #2213

Merged
merged 1 commit into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions devito/tools/data_structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ def unique(self, key):
"""
candidates = self.getall(key)
candidates = [c for c in candidates if c is not None]
if not candidates:
return None

def compare_to_first(v):
first = candidates[0]
Expand Down
21 changes: 20 additions & 1 deletion tests/test_dimension.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
SparseFunction, SparseTimeFunction, Eq, Operator, Constant,
Dimension, DefaultDimension, SubDimension, switchconfig,
SubDomain, Lt, Le, Gt, Ge, Ne, Buffer, sin, SpaceDimension,
CustomDimension, dimensions, configuration)
CustomDimension, dimensions, configuration, norm, Inc, sum)
from devito.ir.iet import (Conditional, Expression, Iteration, FindNodes,
FindSymbols, retrieve_iteration_tree)
from devito.symbolics import indexify, retrieve_functions, IntDiv, INT
Expand Down Expand Up @@ -1636,6 +1636,25 @@ def test_array_shared_w_topofuse(self):

assert_structure(op, ['i,x,y', 'i', 'i,x,y', 'i,x,y'], 'i,x,y,x,y,x,y')

def test_cond_notime(self):
grid = Grid(shape=(10, 10))
time = grid.time_dim

time_under = ConditionalDimension(name='timeu', parent=time, factor=5)
nt = 10

u = TimeFunction(name='u', grid=grid, space_order=2)
usaved = TimeFunction(name='usaved', grid=grid, space_order=2,
time_dim=time_under, save=nt//5+1)
g = Function(name='g', grid=grid)

op = Operator([Eq(usaved, u)])
op(time_m=1, time_M=nt-1, dt=1)

op = Operator([Inc(g, usaved)])
op(time_m=1, time_M=nt-1, dt=1)
assert norm(g, order=1) == norm(sum(usaved, dims=time_under), order=1)


class TestCustomDimension(object):

Expand Down