__setitem__¶
- array.__setitem__(key: int | slice | ellipsis | Tuple[int | slice | ellipsis | array, ...] | array, value: int | float | complex | bool | array, /) None¶
Sets
self[key]tovalue.- 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
keyis 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
valueis 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
valueis anarrayof a different data type thanself, how values are cast to the data type ofselfis implementation defined.