Skip to content

Commit a402c99

Browse files
committed
[Fix] Fix NDArray single-arg subscript crash
NdarrayType.__class_getitem__ crashed when called with a single arg (e.g. NdarrayType[dtype]) because it tried to unpack a non-tuple. Wrap single args in a tuple before passing to __init__.
1 parent 77fccda commit a402c99

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

python/quadrants/types/ndarray_type.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,10 @@ def __init__(
9494
self.boundary = int(to_boundary_enum(boundary))
9595

9696
@classmethod
97-
def __class_getitem__(cls, args, **kwargs):
98-
return cls(*args, **kwargs)
97+
def __class_getitem__(cls, args):
98+
if not isinstance(args, tuple):
99+
args = (args,)
100+
return cls(*args)
99101

100102
def check_matched(self, ndarray_type: NdarrayTypeMetadata, arg_name: str):
101103
# FIXME(Haidong) Cannot use Vector/MatrixType due to circular import

0 commit comments

Comments
 (0)