Skip to content

Commit e7569b1

Browse files
committed
make more generic
1 parent cc235c4 commit e7569b1

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

  • src/bloqade/geometry/dialects/grid

src/bloqade/geometry/dialects/grid/types.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,12 @@ def get_indices(size: int, index: Any) -> ilist.IList[int, Any]:
2222
raise IndexError("Index out of range")
2323

2424
return ilist.IList([index])
25-
elif isinstance(index, Sequence) and all(isinstance(i, int) for i in index):
26-
return ilist.IList(list(index))
27-
else:
28-
raise TypeError("Index must be an int, slice, or IList")
25+
26+
index = ilist.IList(list(index))
27+
if any(not isinstance(i, int) for i in index.data):
28+
raise TypeError("Index must be an int, slice, or Sequence of ints")
29+
30+
return index
2931

3032

3133
@dataclasses.dataclass

0 commit comments

Comments
 (0)