Scipy: vectorized function does not take scalars as arguments

Robert Kern robert.kern at
Wed May 24 12:32:58 EDT 2006

ago wrote:
> Once I vectorize a function it does not acccept scalars anymore. Es
> def f(x): return x*2
> vf = vectorize(f)
> print vf(2)
> AttributeError: 'int' object has no attribute 'astype'
> Is this the intended behaviour?

More or less. It would be nice if it transparently handled the scalars, too, so
if you would like to work on that, we'd be happy to incorporate your changes.

Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth."
  -- Umberto Eco

More information about the Python-list mailing list