Skip to main content
`Ctrl`+`K`

# numpy.ndarray.__class_getitem__

method

ndarray.__class_getitem__($cls, item, /)

  ndarray[shape, dtype]

  Return a parametrized wrapper around the `ndarray` type.

  New in version 1.22.

  Returns:
    alias types.GenericAlias

      A parametrized `ndarray` type.

  See also

  PEP 585

    Type hinting generics in standard collections.

  `numpy.typing.NDArray`

    An 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]]