mypy失败了numpy总和
此代码片段有效:
py -c "import numpy; print(numpy.array([[1,2,3],[4,5,6]]).sum(axis=0) % 2)"
[1 1 1]
但是Mypy出现了一个错误:
py -m mypy -c "import numpy; print(numpy.array([[1,2,3],[4,5,6]]).sum(axis=0) % 2)"
<string>:1: error: Unsupported operand types for % ("number[Any]" and "int")
<string>:1: note: Left operand is of type "Union[number[Any], ndarray]"
Found 1 error in 1 file (checked 1 source file)
这是我的代码段中的mypy错误还是numpy错误或错误?
This code snippet works:
py -c "import numpy; print(numpy.array([[1,2,3],[4,5,6]]).sum(axis=0) % 2)"
[1 1 1]
But mypy gives an error:
py -m mypy -c "import numpy; print(numpy.array([[1,2,3],[4,5,6]]).sum(axis=0) % 2)"
<string>:1: error: Unsupported operand types for % ("number[Any]" and "int")
<string>:1: note: Left operand is of type "Union[number[Any], ndarray]"
Found 1 error in 1 file (checked 1 source file)
Is this a mypy bug or a numpy bug or a bug in my code snippet?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是一个麻烦的错误,直到numpy 1.20.3 https://github.com/numpy/numpy/numpy/问题/18305
This was a numpy bug until numpy 1.20.3 https://github.com/numpy/numpy/issues/18305