def vectorize1(func, args=(), vec_func=False):
 if vec_func:
  def vfunc(x):
   return func(x, *args)
 else:
  def vfunc(x):
   if np.isscalar(x):
    return func(x, *args)
   x = np.asarray(x)
   y0 = func(x[0], *args)
   n = len(x)
   dtype = getattr(y0, 'dtype', type(y0))
   output = np.empty((n,), dtype=dtype)
   output[0] = y0
   for i in xrange(1, n):
    output[i] = func(x[i], *args)
   return output
 return vfunc

def vectorize1 ( func , args = ( ) , vec_func = False ) : if vec_func : def vfunc ( x ) : return func ( x , * args ) else : def vfunc ( x ) : if np . isscalar ( x ) : return func ( x , * args ) x = np . asarray ( x ) y0 = func ( x [ 0 ] , * args ) n = len ( x ) dtype = getattr ( y0 , 'dtype' , type ( y0 ) ) output = np . empty ( ( n , ) , dtype = dtype ) output [ 0 ] = y0 for i in xrange ( 1 , n ) : output [ i ] = func ( x [ i ] , * args ) return output return vfunc
vectorize the call to a function .