MCPcopy
hub / github.com/pydata/xarray / lazy_elemwise_func

Function lazy_elemwise_func

xarray/coding/common.py:89–109  ·  view source on GitHub ↗

Lazily apply an element-wise function to an array. Parameters ---------- array : any valid value of Variable._data func : callable Function to apply to indexed slices of an array. For use with dask, this should be a pickle-able object. dtype : coercible to np.dtyp

(array, func: Callable, dtype: np.typing.DTypeLike | None)

Source from the content-addressed store, hash-verified

87
88
89def lazy_elemwise_func(array, func: Callable, dtype: np.typing.DTypeLike | None):
90 """Lazily apply an element-wise function to an array.
91 Parameters
92 ----------
93 array : any valid value of Variable._data
94 func : callable
95 Function to apply to indexed slices of an array. For use with dask,
96 this should be a pickle-able object.
97 dtype : coercible to np.dtype
98 Dtype for the result of this function.
99
100 Returns
101 -------
102 Either a dask.array.Array or _ElementwiseFunctionArray.
103 """
104 if is_chunked_array(array):
105 chunkmanager = get_chunked_array_type(array)
106
107 return chunkmanager.map_blocks(func, array, dtype=dtype) # type: ignore[arg-type]
108 else:
109 return _ElementwiseFunctionArray(array, func, dtype)
110
111
112def safe_setitem(dest, key: Hashable, value, name: T_Name = None):

Callers 6

decodeMethod · 0.90
decodeMethod · 0.90
decodeMethod · 0.90
decodeMethod · 0.90
decodeMethod · 0.85

Calls 4

is_chunked_arrayFunction · 0.90
get_chunked_array_typeFunction · 0.90
map_blocksMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…