python-3.x - Pycharm中令人困惑的类型提示警告
问题描述
谁能解释为什么 Pycharm 会在这里发出类型警告?
import numpy as np
def test(arr: np.ndarray) -> tuple:
to_return = np.where((arr > 0.1) & (arr < 0.9))
return to_return # marks the text with "Expected type 'tuple', got 'ndarray' instead"
a = np.random.rand(10, 10)
res = test(a)
print(type(res)) #<class 'tuple'>
解决方案
推荐阅读
- api - Gridsome 返回 xml api - graphql 层
- javascript - 我有 6 个弹出窗口同时打开,但希望它们一个一个打开
- c# - 使用 Microsoft Graph v1.0 SDK 创建 OnlineMeeting 时出现 Forbidden 403 错误
- vue.js - 在 Vue JS 中使用方法内部的方法
- python - 如何从我的数据库中获取数据。MySQL 和 Python 使用
- svg - SVG 通过属性更改文本
- python - SVC' 对象没有属性 'feature_importances_'
- wordpress - 使用 ACF 块时强制样式加载到标题中
- python-3.x - 通过 pip3 在 centos7 中安装 mod-wsgi 会抛出“ERROR: Command errored out with exit status 1”
- java - 使用 Stax 解析器解析 XML 1.1 文档时出错