469,360 Members | 1,728 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,360 developers. It's quick & easy.

Scipy: vectorized function does not take scalars as arguments

ago
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?

May 24 '06 #1
3 1915
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

May 24 '06 #2
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?


Vectorize handles scalars in recent versions of NumPy. Which version do
you have?

-Travis
May 24 '06 #3
ago
I have installed numpy-0.9.6 I haven't tried 0.9.8.

May 25 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

41 posts views Thread by Materialised | last post: by
1 post views Thread by tkpmep | last post: by
reply views Thread by Julien Fiore | last post: by
1 post views Thread by tkpmep | last post: by
18 posts views Thread by robert | last post: by
4 posts views Thread by HYRY | last post: by
1 post views Thread by T.Crane | last post: by
12 posts views Thread by viza | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.