[Numpy-discussion] Problems with long
Travis E. Oliphant
oliphant@enthought....
Sat Jan 26 06:49:06 CST 2008
Tom Johnson wrote:
> Hi, I'm having some troubles with long.
>
>
>>>> from numpy import log
>>>> log(8463186938969424928L)
>>>>
> 43.5822574833
>
>>>> log(10454852688145851272L)
>>>>
> <type 'exceptions.AttributeError'>: 'long' object has no attribute 'log'
>
The problem is that the latter long integer is too big to fit into an
int64 (long long) and so it converts it to an object array. The default
behavior of log on object arrays is to look for a method on each element
of the array called log and call that.
Your best bet is to convert to double before calling log
log(float(10454852688145851272L))
-Travis O.
More information about the Numpy-discussion
mailing list