Skip to content

Commit

Permalink
Merge pull request #2213 from devitocodes/arg-fix-2
Browse files Browse the repository at this point in the history
compiler: fix arg processing for empty arg update
  • Loading branch information
FabioLuporini authored Sep 21, 2023
2 parents 237a4a8 + 20b2481 commit c36a25d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
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

0 comments on commit c36a25d

Please sign in to comment.