dask 2021.10.0

ParametersReturnsBackRef
setitem(x, v, indices)

Assign v to indices of x.

Parameters

x : numpy array

The array to be assigned to.

v : numpy array

The values which will be assigned.

indices : list of `slice`, `int`, or numpy array

The indices describing the elements of x to be assigned from v. One index per axis.

Note that an individual index can not be a :None:None:`list`, use a 1-d numpy array instead.

If a 1-d numpy array index contains the non-valid value of the size of the corresponding dimension of x, then those index elements will be removed prior to the assignment (see :None:None:`block_index_from_1d_index` function).

Returns

numpy array

A new independent array with assigned elements, unless v is empty (i.e. has zero size) in which case then the input array is returned and the indices are ignored.

Chunk function of setitem_array .

Examples

This example is valid syntax, but we were not able to check execution
>>> x = np.arange(8).reshape(2, 4)
... setitem(x, np.array(-99), [np.array([False, True])]) array([[ 0, 1, 2, 3], [-99, -99, -99, -99]])
This example is valid syntax, but we were not able to check execution
>>> x
array([[0, 1, 2, 3],
       [4, 5, 6, 7]])
This example is valid syntax, but we were not able to check execution
>>> setitem(x, np.array([-88, -99]), [slice(None), np.array([1, 3])])
array([[  0, -88,   2, -99],
       [  4, -88,   6, -99]])
This example is valid syntax, but we were not able to check execution
>>> setitem(x, -x, [slice(None)])
array([[ 0, -1, -2, -3],
       [-4, -5, -6, -7]])
This example is valid syntax, but we were not able to check execution
>>> x
array([[0, 1, 2, 3],
       [4, 5, 6, 7]])
This example is valid syntax, but we were not able to check execution
>>> setitem(x, np.array([-88, -99]), [slice(None), np.array([4, 4, 3, 4, 1, 4])])
array([[  0, -99,   2, -88],
       [  4, -99,   6, -88]])
This example is valid syntax, but we were not able to check execution
>>> value = np.where(x < 0)[0]
... value.size 0
This example is valid syntax, but we were not able to check execution
>>> y = setitem(x, value, [Ellipsis])
... y is x True
See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

dask.array.slicing.setitem

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


File: /dask/array/slicing.py#2102
type: <class 'function'>
Commit: