[Numpy-discussion] Strange exp
robert.kern at gmail.com
Thu Aug 31 13:35:11 CDT 2006
Angelo Secchi wrote:
> I have the following script
> import fileinput
> import string
> from math import *
> from scipy import *
> from rpy import *
> import Numeric
> import shelve
> import sys
> def dpolya1(n,N,b,a):
> return probs
> and I observe the following "strange" (for me of course) behaviour
> <type 'float64scalar'>
> Traceback (most recent call last):
> File "<stdin>", line 1, in ?
> AttributeError: 'numpy.ndarray' object has no attribute 'exp'
> I do not understand what's wrong. Any help?
Probably rpy (which still uses Numeric, right?) is exposing Numeric's exp()
implementation and overriding the one that you got from scipy (which is numpy's,
I presume). When Numeric's exp() is confronted with an object that it doesn't
recognize, it looks for a .exp() method to call.
If you want to avoid this situation in the future, don't use the "from foo
import *" form. It makes debugging problems like this difficult.
"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 Numpy-discussion