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

Function load_store_chunk

dask/array/core.py:4757–4825  ·  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

4755
4756
4757def load_store_chunk(
4758 x: Any,
4759 out: Any,
4760 index: slice | None,
4761 region: slice | None,
4762 lock: Any,
4763 return_stored: bool,
4764 load_stored: bool,
4765) -> Any:
4766 """
4767 A function inserted in a Dask graph for storing a chunk.
4768
4769 Parameters
4770 ----------
4771 x: array-like
4772 An array (potentially a NumPy one)
4773 out: array-like
4774 Where to store results.
4775 index: slice-like
4776 Where to store result from ``x`` in ``out``.
4777 lock: Lock-like or False
4778 Lock to use before writing to ``out``.
4779 return_stored: bool
4780 Whether to return ``out``.
4781 load_stored: bool
4782 Whether to return the array stored in ``out``.
4783 Ignored if ``return_stored`` is not ``True``.
4784
4785 Returns
4786 -------
4787
4788 If return_stored=True and load_stored=False
4789 out
4790 If return_stored=True and load_stored=True
4791 out[index]
4792 If return_stored=False and compute=False
4793 None
4794
4795 Examples
4796 --------
4797
4798 >>> a = np.ones((5, 6))
4799 >>> b = np.empty(a.shape)
4800 >>> load_store_chunk(a, b, (slice(None), slice(None)), None, False, False, False)
4801 """
4802 if region:
4803 # Equivalent to `out[region][index]`
4804 if index:
4805 index = fuse_slice(region, index)
4806 else:
4807 index = region
4808 if lock:
4809 lock.acquire()
4810 try:
4811 if x is not None and x.size != 0:
4812 if is_arraylike(x):
4813 out[index] = x
4814 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