MCPcopy Create free account
hub / github.com/dask/dask / load_store_chunk

Function load_store_chunk

dask/array/core.py:4560–4628  ·  view source on GitHub ↗

A function inserted in a Dask graph for storing a chunk. Parameters ---------- x: array-like An array (potentially a NumPy one) out: array-like Where to store results. index: slice-like Where to store result from ``x`` in ``out``. lock: Lock-like

(
    x: Any,
    out: Any,
    index: slice | None,
    region: slice | None,
    lock: Any,
    return_stored: bool,
    load_stored: bool,
)

Source from the content-addressed store, hash-verified

4558
4559
4560def load_store_chunk(
4561 x: Any,
4562 out: Any,
4563 index: slice | None,
4564 region: slice | None,
4565 lock: Any,
4566 return_stored: bool,
4567 load_stored: bool,
4568) -> Any:
4569 """
4570 A function inserted in a Dask graph for storing a chunk.
4571
4572 Parameters
4573 ----------
4574 x: array-like
4575 An array (potentially a NumPy one)
4576 out: array-like
4577 Where to store results.
4578 index: slice-like
4579 Where to store result from ``x`` in ``out``.
4580 lock: Lock-like or False
4581 Lock to use before writing to ``out``.
4582 return_stored: bool
4583 Whether to return ``out``.
4584 load_stored: bool
4585 Whether to return the array stored in ``out``.
4586 Ignored if ``return_stored`` is not ``True``.
4587
4588 Returns
4589 -------
4590
4591 If return_stored=True and load_stored=False
4592 out
4593 If return_stored=True and load_stored=True
4594 out[index]
4595 If return_stored=False and compute=False
4596 None
4597
4598 Examples
4599 --------
4600
4601 >>> a = np.ones((5, 6))
4602 >>> b = np.empty(a.shape)
4603 >>> load_store_chunk(a, b, (slice(None), slice(None)), None, False, False, False)
4604 """
4605 if region:
4606 # Equivalent to `out[region][index]`
4607 if index:
4608 index = fuse_slice(region, index)
4609 else:
4610 index = region
4611 if lock:
4612 lock.acquire()
4613 try:
4614 if x is not None and x.size != 0:
4615 if is_arraylike(x):
4616 out[index] = x
4617 else:

Callers 2

test_load_store_chunkFunction · 0.90
load_chunkFunction · 0.85

Calls 4

fuse_sliceFunction · 0.90
is_arraylikeFunction · 0.90
acquireMethod · 0.45
releaseMethod · 0.45

Tested by 1

test_load_store_chunkFunction · 0.72