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)
| 87 | |
| 88 | |
| 89 | def 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 | |
| 112 | def safe_setitem(dest, key: Hashable, value, name: T_Name = None): |
no test coverage detected
searching dependent graphs…