You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
np.exp raises AttributeError: 'int' object has no attribute 'exp' when called with an integer greater than 2**64-1.
Expected behavior
Return np.inf as for other large integer values (e.g. for 2**63).
Assumption
Such integers are treated internally as object and hence numpy tried to call the exp-function on the instance (similar to np.exp(np.asarray([2], dtype=object))). However this is completely unexpected since in Python 3 all integers have the same type (nonetheless the must be stored differently in memory).
System
$ uname -a
Linux MyPC 4.4.0-128-generic #154-Ubuntu SMP Fri May 25 14:15:18 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
$ python
Python 3.6.2 (default, Jul 17 2017, 23:14:31)
[GCC 5.4.0 20160609] on linux
Code Example
>>>fromnumpyimportexp>>>exp(2**64) # Would expect np.inf as return value.Traceback (mostrecentcalllast):
File"<stdin>", line1, in<module>AttributeError: 'int'objecthasnoattribute'exp'>>>exp(2**63) # Here it does.__main__:1: RuntimeWarning: overflowencounteredinexpinf>>>type(2**63) istype(2**64)
True
The text was updated successfully, but these errors were encountered:
This is very not true in numpy, which has 10 different types of integer. Unfortunately, pythons int can be too big to fit in any of them.
The only sensible way for us to support np.exp(2**64) is to fix np.exp(np.array(1, dtype=object)). There are open PRs about that (#10820 is related, for instance)
Summary
np.exp
raisesAttributeError: 'int' object has no attribute 'exp'
when called with an integer greater than2**64-1
.Expected behavior
Return
np.inf
as for other large integer values (e.g. for2**63
).Assumption
Such integers are treated internally as
object
and hence numpy tried to call the exp-function on the instance (similar tonp.exp(np.asarray([2], dtype=object))
). However this is completely unexpected since in Python 3 all integers have the same type (nonetheless the must be stored differently in memory).System
$ uname -a Linux MyPC 4.4.0-128-generic #154-Ubuntu SMP Fri May 25 14:15:18 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux $ python Python 3.6.2 (default, Jul 17 2017, 23:14:31) [GCC 5.4.0 20160609] on linux
Code Example
The text was updated successfully, but these errors were encountered: