__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.

  • value must be promoted to the data type of self according to Type Promotion Rules. If this is not supported according to Type Promotion Rules, behavior is unspecified and thus implementation-defined.

Changed in version 2025.12: Specified Type Promotion Rules when value is an array.