numeric.scipy.org    Version 1.0b1 API Documentation generated by Endo 2006-08-14

vectorize(somefunction, otypes=None, doc=None) Generalized Function class.

Description:

Define a vectorized function which takes nested sequence objects or numpy arrays as inputs and returns a numpy array as output, evaluating the function over successive tuples of the input arrays like the python map function except it uses the broadcasting rules of numpy.

Input:

somefunction -- a Python function or method

Example:

def myfunc(a, b):
if a > b:
return a-b
else
return a+b

vfunc = vectorize(myfunc)

>>> vfunc([1, 2, 3, 4], 2)
array([3, 4, 1, 2])

Method summary

Methods