numpy 1.22.4 Pypi GitHub Homepage
Other Docs
NotesParametersReturnsBackRef
frompyfunc(func, /, nin, nout, *[, identity])

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 :None:None:`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.

Takes an arbitrary Python function and returns a NumPy ufunc.

See Also

vectorize

Evaluates pyfunc over input arrays using broadcasting rules of numpy.

Examples

Use frompyfunc to add broadcasting to the Python function oct :

>>> oct_array = np.frompyfunc(oct, 1, 1)
... oct_array(np.array((10, 30, 100))) array(['0o12', '0o36', '0o144'], dtype=object)
>>> np.array((oct(10), oct(30), oct(100))) # for comparison
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.frompyfunc numpy.vectorize numpy.lib.function_base.vectorize.__call__

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


GitHub : None#None
type: <class 'builtin_function_or_method'>
Commit: