Python error when calling NumPy from class method with map

前端 未结 5 1674
我寻月下人不归
我寻月下人不归 2021-02-12 23:58

The following code throws me the error:

Traceback (most recent call last):
  File \"\", line 25, in 
    sol = anna.main()
  File \"\", line 17, in         


        
5条回答
  •  庸人自扰
    2021-02-13 00:23

    As others have noticed, this boils down to the fact that np.sqrt(7131 ** 5) works but np.sqrt(7132 ** 5) returns an error:

    import numpy as np
    
    print(np.sqrt(7131 ** 5))
    print(np.sqrt(7132 ** 5))
    
    # 4294138928.9
    Traceback (most recent call last):
      File "main.py", line 4, in 
        print(np.sqrt(7132 ** 5))
    AttributeError: 'int' object has no attribute 'sqrt'
    

    Since np.sqrt docs don't mention any bounds on the argument, I'd consider this a numpy bug.

提交回复
热议问题