Angelo Secchi wrote: > Hi, > 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): > a=float(a) > b=float(b) > L=784 > > probs=((special.gammaln(N+1)+special.gammaln(L*(a/b))+special.gammaln((a/b)+n)+special.gammaln((a/b)*(L-1)+N-n))-(special.gammaln(L*(a/b)+N)+special.gammaln(a/b)+special.gammaln(n+1)+special.gammaln(N-n+1)+special.gammaln(L*(a/b)-(a/b))))#) > return probs > > and I observe the following "strange" (for me of course) behaviour > >>>> dpolya1(1,2,0.5,0.4) > -5.9741312822170585 >>>> type(dpolya1(1,2,0.5,0.4)) > <type 'float64scalar'> >>>> exp(dpolya1(1,2,0.5,0.4)) > 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. -- 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 ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion