numpy.ndarray.__class_getitem__#
method
- ndarray.__class_getitem__($cls, item, /)#
ndarray[shape, dtype]
Return a parametrized wrapper around the
ndarraytype.New in version 1.22.
- Returns:
- aliastypes.GenericAlias
A parametrized
ndarraytype.
See also
- PEP 585
Type hinting generics in standard collections.
numpy.typing.NDArrayAn ndarray alias generic w.r.t. its
dtype.type.
Examples
>>> import numpy as np
>>> np.ndarray[tuple[int], np.dtype[np.uint8]] numpy.ndarray[tuple[int], numpy.dtype[numpy.uint8]]