This is the wrong error message - AttributeError: does the "int" object have the "log2" attribute?

I assume this is due to integer type overflow. But why a weird error message?

In [36]: import numpy as np

In [37]: np.log2(2**63)
Out[37]: 63.0

In [38]: np.log2(2**64)
Traceback (most recent call last):

  File "<ipython-input-38-f1b1c814f08c>", line 1, in <module>
    np.log2(2**64)

AttributeError: 'int' object has no attribute 'log2'

Why does he say that he has “no attribute” and not something like “integer overflow”? Or did I misunderstand the cause of the error? I see how this error message can be very confusing, helping to find where the problem is.

+4
source share

All Articles