MCPcopy
hub / github.com/dask/dask / setitem_array

Function setitem_array

dask/array/slicing.py:1464–2027  ·  view source on GitHub ↗

Master function for array assignment. This function, that is intended to be called by `Array.__setitem__`, creates a new dask that assigns values to each block that is touched by the indices, leaving other blocks unchanged. Each block that overlaps the indices is assigned from

(out_name, array, indices, value)

Source from the content-addressed store, hash-verified

1462
1463
1464def setitem_array(out_name, array, indices, value):
1465 """Master function for array assignment.
1466
1467 This function, that is intended to be called by
1468 `Array.__setitem__`, creates a new dask that assigns values to
1469 each block that is touched by the indices, leaving other blocks
1470 unchanged.
1471
1472 Each block that overlaps the indices is assigned from the
1473 appropriate part of the assignment value. The dasks of these value
1474 parts are included in the output dask dictionary, as are the dasks
1475 of any 1-d dask array indices. This ensures that the dask array
1476 assignment value and any dask array indices are not computed until
1477 the `Array.__setitem__` operation is computed.
1478
1479 The part of the assignment value applies to block is created as a
1480 "getitem" slice of the full assignment value.
1481
1482 Parameters
1483 ----------
1484 out_name : `str`
1485 The dask variable output name.
1486 array : dask array
1487 The dask array that is being assigned to.
1488 indices : numpy-style indices
1489 Indices to array defining the elements to be assigned.
1490 value : dask array
1491 The assignment value, i.e. the values which will be assigned
1492 to elements of array.
1493
1494 Returns
1495 -------
1496 dsk : `dict`
1497 A dictionary where the keys are new unique tokens for each
1498 block of the form
1499
1500 (out_name, dim_index[, dim_index[, ...]])
1501
1502 and the values are either
1503
1504 (key,)
1505
1506 or
1507
1508 (setitem, key, v_key, block_indices)
1509
1510 where key is an existing top-level dask key of array.
1511
1512 The first case occurs when the block represented by key does
1513 not overlap the indices.
1514
1515 The second case occurs when the block represented by key does
1516 overlap the indices. setitem is the chunk assignment function;
1517 v_key is the dask key of the part of the assignment value
1518 that corresponds to the block; and block_indices are the
1519 assignment indices that apply to the block.
1520
1521 The dictionary also includes any additional key/value pairs

Callers 1

__setitem__Method · 0.90

Calls 13

is_dask_collectionFunction · 0.90
cached_cumsumFunction · 0.90
flattenFunction · 0.90
parse_assignment_indicesFunction · 0.85
maxFunction · 0.85
concatenate_array_chunksFunction · 0.85
divmodFunction · 0.70
mergeFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…