Skip to content

Commit

Permalink
Merge pull request #2512 from devitocodes/constant_condition
Browse files Browse the repository at this point in the history
tests: Add test for using a Constant as a condition in a ConditionalDimension
  • Loading branch information
FabioLuporini authored Jan 9, 2025
2 parents 6615058 + 4715350 commit 18ae4f1
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/test_dimension.py
Original file line number Diff line number Diff line change
Expand Up @@ -1288,6 +1288,20 @@ def test_no_index_symbolic(self):
op = Operator(eq)
op.cfunction

@pytest.mark.parametrize('value', [0, 1])
def test_constant_as_condition(self, value):
x = Dimension('x')

c = Constant(name="c", dtype=np.int8, value=value)
cd = ConditionalDimension(name="cd", parent=x, condition=c)

f = Function(name='f', dimensions=(x,), shape=(11,), dtype=np.int32)

op = Operator(Eq(f, 1, implicit_dims=cd))
op.apply()

assert np.all(f.data == value)

def test_symbolic_factor(self):
"""
Test ConditionalDimension with symbolic factor (provided as a Constant).
Expand Down

0 comments on commit 18ae4f1

Please sign in to comment.