Skip to content

Commit

Permalink
misc: fix UnboundTuple for None partile
Browse files Browse the repository at this point in the history
  • Loading branch information
mloubout committed Nov 1, 2023
1 parent 465e72b commit 306e975
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion devito/tools/data_structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,7 @@ def __new__(cls, *items, **kwargs):
nitems.append(i)
elif isinstance(i, Iterable):
nitems.append(UnboundTuple(*i))
elif i is not None:
else:
nitems.append(i)

obj = super().__new__(cls, tuple(nitems))
Expand Down
18 changes: 17 additions & 1 deletion tests/test_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import time

from devito.tools import (UnboundedMultiTuple, ctypes_to_cstr, toposort,
filter_ordered, transitive_closure)
filter_ordered, transitive_closure, UnboundTuple)
from devito.types.basic import Symbol


Expand Down Expand Up @@ -120,3 +120,19 @@ def test_unbounded_multi_tuple():

ub.iter()
assert ub.next() == 3


def test_unbound_tuple():
# Make sure we don't drop needed None for 2.5d
ub = UnboundTuple(None, None)
assert len(ub) == 2
assert ub[10] is None

ub = UnboundTuple(1, 2, 3)
assert len(ub) == 3
assert ub[10] == 3
assert ub[1:4] == (2, 3, 3)
assert ub.next() == 1
assert ub.next() == 2
ub.iter()
assert ub.next() == 1

0 comments on commit 306e975

Please sign in to comment.