Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions python/quadrants/types/ndarray_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,10 @@ def __init__(
self.boundary = int(to_boundary_enum(boundary))

@classmethod
def __class_getitem__(cls, args, **kwargs):
return cls(*args, **kwargs)
def __class_getitem__(cls, args):
if not isinstance(args, tuple):
args = (args,)
return cls(*args)

def check_matched(self, ndarray_type: NdarrayTypeMetadata, arg_name: str):
# FIXME(Haidong) Cannot use Vector/MatrixType due to circular import
Expand Down
6 changes: 6 additions & 0 deletions tests/python/test_ndarray_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,9 @@ def test_ndarray_typing_square_brackets():
b[1, 1] = 5
some_kernel(a, b)
assert a[1, 1] == 5 + 2


def test_ndarray_typing_single_arg():
t = qd.types.NDArray[qd.i32]
assert t.dtype == qd.i32
assert t.ndim is None
Loading