Python numpy arctan2参数根据语法导致ValueError
要复制的代码:Python numpy arctan2参数根据语法导致ValueError,python,numpy,Python,Numpy,要复制的代码: 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
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
我使用的版本:
- 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]
- NumPy 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'
^
numpy.arctan2(x1,x2,/,out=None,*,where=True,casting='same_-kind',order='K',dtype=None,subok=True[,signature,extobj])=您在哪里找到了umath.py
文件?它似乎不存在于我的numpy副本中。据我所知,arctan2
驻留在计算机生成的C文件中。我带着PyCharm跳了进去。但这个文件似乎并不存在,而是由generator 1.145生成的:顶层状态的注释“来自/usr/local/lib/python3.6/site-packages/numpy/core/umath.cpython-36m-x86_64-linux-gnu.so”。为了避免混淆,我在问题中删除了对它的提及。现在很少提到它(AFAIK主要是数学函数),并且只涉及用C实现的函数。
numpy.arctan2(x1, x2, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj]) = <ufunc 'arctan2'
^