__setitem__

array.__setitem__(key: Union[int, slice, ellipsis, Tuple[Union[int, slice, ellipsis], ...], array], value: Union[int, float, bool, array], /) None

Sets self[key] to value.

Parameters
  • self (array) – array instance.

  • key (Union[int, slice, ellipsis, Tuple[Union[int, slice, ellipsis], ...], array]) – index key.

  • value (Union[int, float, bool, array]) – value(s) to set. Must be compatible with self[key] (see Broadcasting).

Note

Setting array values must not affect the data type of self.

When value is a Python scalar (i.e., int, float, bool), behavior must follow specification guidance on mixing arrays with Python scalars (see Type Promotion Rules).

When value is an array of a different data type than self, how values are cast to the data type of self is implementation defined.