[Numpy-discussion] Strange Error with NumPy
Thu Aug 6 17:15:14 CDT 2009
On Thu, Aug 6, 2009 at 17:01, Nanime Puloski<email@example.com> wrote:
> Can anyone explain to me why I receive an error(AtrributeError) in NumPy
> when I do numpy.sin(2**64), but not when I do numpy.sin(2.0**64),
> numpy.sin(float(2**64)) or even numpy.sin(2)?
> Where is the root problem in all of this?
numpy deals with objects that can be natively represented by the C
numerical types on your machine. On your machine 2**64 gives you a
Python long object which cannot be converted to one of the native C
numerical types, so numpy.sin() treats it as a regular Python object.
The default implementation of all of the ufuncs when faced with a
Python object it doesn't know about is to look for a method on the
object of the same name. long.sin() does not exist, so you get an
"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