__setitem__

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

Sets self[key] to value.

Parameters:
  • self (array) – array instance.

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

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

Notes

  • See Indexing for details on supported indexing semantics.

    Note

    Indexing semantics when key is an integer array or a tuple of integers and integer arrays is currently unspecified and thus implementation-defined. This will be revisited in a future revision of this standard.

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

  • When value is a Python scalar (i.e., int, float, complex, 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.