MCPcopy Index your code
hub / github.com/dask/dask / apply_gufunc

Function apply_gufunc

dask/array/_array_expr/_gufunc.py:173–532  ·  view source on GitHub ↗

Apply a generalized ufunc or similar python function to arrays. ``signature`` determines if the function consumes or produces core dimensions. The remaining dimensions in given input arrays (``*args``) are considered loop dimensions and are required to broadcast naturally again

(
    func,
    signature,
    *args,
    axes=None,
    axis=None,
    keepdims=False,
    output_dtypes=None,
    output_sizes=None,
    vectorize=None,
    allow_rechunk=False,
    meta=None,
    **kwargs,
)

Source from the content-addressed store, hash-verified

171
172
173def apply_gufunc(
174 func,
175 signature,
176 *args,
177 axes=None,
178 axis=None,
179 keepdims=False,
180 output_dtypes=None,
181 output_sizes=None,
182 vectorize=None,
183 allow_rechunk=False,
184 meta=None,
185 **kwargs,
186):
187 """
188 Apply a generalized ufunc or similar python function to arrays.
189
190 ``signature`` determines if the function consumes or produces core
191 dimensions. The remaining dimensions in given input arrays (``*args``)
192 are considered loop dimensions and are required to broadcast
193 naturally against each other.
194
195 In other terms, this function is like ``np.vectorize``, but for
196 the blocks of dask arrays. If the function itself shall also
197 be vectorized use ``vectorize=True`` for convenience.
198
199 Parameters
200 ----------
201 func : callable
202 Function to call like ``func(*args, **kwargs)`` on input arrays
203 (``*args``) that returns an array or tuple of arrays. If multiple
204 arguments with non-matching dimensions are supplied, this function is
205 expected to vectorize (broadcast) over axes of positional arguments in
206 the style of NumPy universal functions [1]_ (if this is not the case,
207 set ``vectorize=True``). If this function returns multiple outputs,
208 ``output_core_dims`` has to be set as well.
209 signature: string
210 Specifies what core dimensions are consumed and produced by ``func``.
211 According to the specification of numpy.gufunc signature [2]_
212 *args : numeric
213 Input arrays or scalars to the callable function.
214 axes: List of tuples, optional, keyword only
215 A list of tuples with indices of axes a generalized ufunc should operate on.
216 For instance, for a signature of ``"(i,j),(j,k)->(i,k)"`` appropriate for
217 matrix multiplication, the base elements are two-dimensional matrices
218 and these are taken to be stored in the two last axes of each argument. The
219 corresponding axes keyword would be ``[(-2, -1), (-2, -1), (-2, -1)]``.
220 For simplicity, for generalized ufuncs that operate on 1-dimensional arrays
221 (vectors), a single integer is accepted instead of a single-element tuple,
222 and for generalized ufuncs for which all outputs are scalars, the output
223 tuples can be omitted.
224 axis: int, optional, keyword only
225 A single axis over which a generalized ufunc should operate. This is a short-cut
226 for ufuncs that operate over a single, shared core dimension, equivalent to passing
227 in axes with entries of (axis,) for each single-core-dimension argument and ``()`` for
228 all others. For instance, for a signature ``"(i),(i)->()"``, it is equivalent to passing
229 in ``axes=[(axis,), (axis,), ()]``.
230 keepdims: bool, optional, keyword only

Calls 15

apply_infer_dtypeFunction · 0.90
meta_from_arrayFunction · 0.90
asarrayFunction · 0.90
blockwiseFunction · 0.90
flattenFunction · 0.90
new_collectionFunction · 0.90
maxFunction · 0.85
setClass · 0.85
GUfuncLeafExprClass · 0.85
splitMethod · 0.80
_parse_gufunc_signatureFunction · 0.70
_validate_normalize_axesFunction · 0.70

Used in the wild real call sites across dependent graphs

searching dependent graphs…