Movatterモバイル変換


[0]ホーム

URL:


SciPy

numpy.frompyfunc

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 Pythonfunction (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 byfunc.

Returns:
out:ufunc

Returns a NumPy universal function (ufunc) object.

See also

vectorize
evaluates pyfunc over input arrays using broadcasting rules of numpy

Notes

The returned ufunc always returns PyObject arrays.

Examples

Use frompyfunc to add broadcasting to the Python functionoct:

>>>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 comparisonarray(['012', '036', '0144'],      dtype='|S4')

Previous topic

numpy.vectorize.__call__

Next topic

numpy.piecewise

Quick search

  • © Copyright 2008-2018, The SciPy community.
  • Last updated on Jul 24, 2018.
  • Created usingSphinx 1.6.6.

[8]ページ先頭

©2009-2025 Movatter.jp