要重现的代码:
import numpy as np
y1, y2 = [5, 3]
print(np.arctan2(y1, y2)) # Output: 1.0303768265243125
print(np.arctan2(x1=y1, x2=y2))
# Output:
#---------------------------------------------------------------------------
#ValueError Traceback (most recent call last)
#<ipython-input-13-b7d0f788df1f> in <module>()
#----> 1 np.arctan2(x1=y1, x2=y2)
#ValueError: invalid number of arguments
我无法解释抛出的价值错误。我希望两者在语义上是相同的。这是Python,Numpy还是我缺乏理解?
这是 Numpy 中 arctan2 的定义:
def arctan2(x1, x2, *args, **kwargs)
我使用的版本:
- Linux-4.13.0-38-generic-x86_64-with-debian-stretch-sid
- Python 3.6.1(默认,2017 年 6 月 16 日 16:00:03([GCC 5.4.0 20160609]
- 数字 1.14.2
参数
x1
和x2
是所谓的仅位置参数。这在arctan2
文档中由函数签名中的/
字符指示:
numpy.arctan2(x1, x2, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj]) = <ufunc 'arctan2'
^