Jose Amoreira wrote: > I am trying to define a constant vectorized function, that is, one that > returns 1. (for instance) when called with a scalar argument x and that > returns array([1.,1.,1.]) when the argument is a three-element array, etc.
With the help of google I found http://docs.scipy.org/doc/numpy/reference/generated/numpy.frompyfunc.html >>> import numpy >>> def f(x): return 42 ... >>> f = numpy.frompyfunc(f, 1, 1) >>> f(1) 42 >>> f(numpy.zeros(7)) array([42, 42, 42, 42, 42, 42, 42], dtype=object) _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor