Skip to content

Commit

Permalink
tests: Add test for using a Constant as a condition in a ConditionalD…
Browse files Browse the repository at this point in the history
…imension
  • Loading branch information
EdCaunt committed Jan 8, 2025
1 parent 6615058 commit 4715350
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 4715350

Please sign in to comment.