Python error when calling NumPy from class method with map

前端 未结 5 2236
春和景丽
春和景丽 2021-02-12 23:52

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:34

    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.

提交回复
热议问题