numpy / 1.23 / reference / generated / numpy.ndarray.__class_getitem__.html

numpy.ndarray.__class_getitem__

method

ndarray.__class_getitem__(item, /)

Return a parametrized wrapper around the ndarray type.

New in version 1.22.

Returns
aliastypes.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.

Notes

This method is only available for python 3.9 and later.

Examples

>>> from typing import Any
>>> import numpy as np
>>> np.ndarray[Any, np.dtype[Any]]
numpy.ndarray[typing.Any, numpy.dtype[typing.Any]]

© 2005–2022 NumPy Developers
Licensed under the 3-clause BSD License.
https://numpy.org/doc/1.23/reference/generated/numpy.ndarray.__class_getitem__.html