numpy.frompyfunc(func, nin, nout) 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).
| Parameters: |
func : Python function object An arbitrary Python function. nin : int The number of input arguments. nout : int The number of objects returned by |
|---|---|
| Returns: |
out : ufunc Returns a NumPy universal function ( |
See also
vectorize
The returned ufunc always returns PyObject arrays.
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([012, 036, 0144], dtype=object)
>>> np.array((oct(10), oct(30), oct(100))) # for comparison
array(['012', '036', '0144'],
dtype='|S4')
© 2008–2017 NumPy Developers
Licensed under the NumPy License.
https://docs.scipy.org/doc/numpy-1.14.2/reference/generated/numpy.frompyfunc.html