dask 2021.10.0

NotesParametersReturnsBackRef
frompyfunc(func, /, nin, nout, *[, identity])

Some inconsistencies with the Dask version may exist.

Takes an arbitrary Python function and returns a NumPy ufunc.

Can be used, for example, to add broadcasting to a built-in Python function (see Examples section).

Notes

The returned ufunc always returns PyObject arrays.

Parameters

func : Python function object

An arbitrary Python function.

nin : int

The number of input arguments.

nout : int

The number of objects returned by func .

identity : object, optional

The value to use for the :None:None:`~numpy.ufunc.identity` attribute of the resulting object. If specified, this is equivalent to setting the underlying C identity field to PyUFunc_IdentityValue . If omitted, the identity is set to PyUFunc_None . Note that this is _not_ equivalent to setting the identity to None , which implies the operation is reorderable.

Returns

out : ufunc

Returns a NumPy universal function ( ufunc ) object.

This docstring was copied from numpy.frompyfunc.

See Also

vectorize

Evaluates pyfunc over input arrays using broadcasting rules of numpy.

Examples

Use frompyfunc to add broadcasting to the Python function oct :

This example is valid syntax, but we were not able to check execution
>>> oct_array = np.frompyfunc(oct, 1, 1)  # doctest: +SKIP
... oct_array(np.array((10, 30, 100))) # doctest: +SKIP array(['0o12', '0o36', '0o144'], dtype=object)
This example is valid syntax, but we were not able to check execution
>>> np.array((oct(10), oct(30), oct(100))) # for comparison  # doctest: +SKIP
array(['0o12', '0o36', '0o144'], dtype='<U5')
See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

dask.array.ufunc.da_frompyfunc

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


File: /dask/array/ufunc.py#81
type: <class 'function'>
Commit: