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

Method __setitem__

numpy/array_api/_array_object.py:736–753  ·  view source on GitHub ↗

Performs the operation __setitem__.

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

Source from the content-addressed store, hash-verified

734 return self.__class__._new(res)
735
736 def __setitem__(
737 self,
738 key: Union[
739 int, slice, ellipsis, Tuple[Union[int, slice, ellipsis], ...], Array
740 ],
741 value: Union[int, float, bool, Array],
742 /,
743 ) -> None:
744 """
745 Performs the operation __setitem__.
746 """
747 # Note: Only indices required by the spec are allowed. See the
748 # docstring of _validate_index
749 self._validate_index(key)
750 if isinstance(key, Array):
751 # Indexing self._array with array_api arrays can be erroneous
752 key = key._array
753 self._array.__setitem__(key, asarray(value)._array)
754
755 def __sub__(self: Array, other: Union[int, float, Array], /) -> Array:
756 """

Callers

nothing calls this directly

Calls 2

_validate_indexMethod · 0.95
asarrayFunction · 0.70

Tested by

no test coverage detected