MCPcopy Create free account
hub / github.com/numpy/numpy / __getitem__

Method __getitem__

numpy/array_api/_array_object.py:543–564  ·  view source on GitHub ↗

Performs the operation __getitem__.

(
        self: Array,
        key: Union[
            int,
            slice,
            ellipsis,
            Tuple[Union[int, slice, ellipsis, None], ...],
            Array,
        ],
        /,
    )

Source from the content-addressed store, hash-verified

541 return self.__class__._new(res)
542
543 def __getitem__(
544 self: Array,
545 key: Union[
546 int,
547 slice,
548 ellipsis,
549 Tuple[Union[int, slice, ellipsis, None], ...],
550 Array,
551 ],
552 /,
553 ) -> Array:
554 """
555 Performs the operation __getitem__.
556 """
557 # Note: Only indices required by the spec are allowed. See the
558 # docstring of _validate_index
559 self._validate_index(key)
560 if isinstance(key, Array):
561 # Indexing self._array with array_api arrays can be erroneous
562 key = key._array
563 res = self._array.__getitem__(key)
564 return self._new(res)
565
566 def __gt__(self: Array, other: Union[int, float, Array], /) -> Array:
567 """

Callers

nothing calls this directly

Calls 2

_validate_indexMethod · 0.95
_newMethod · 0.95

Tested by

no test coverage detected