栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

FutureWarning:不推荐将非元组序列用于多维索引,请使用`arr [tuple(seq)]`

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

FutureWarning:不推荐将非元组序列用于多维索引,请使用`arr [tuple(seq)]`

更全面的追溯将是很好的。我的猜测是,

seaborn.distplot
使用
scipy.stats
计算的东西。错误发生在

def _compute_qth_percentile(sorted, per, interpolation_method, axis):    ....    indexer = [slice(None)] * sorted.ndim    ...    indexer[axis] = slice(i, i + 2)    ...    return np.add.reduce(sorted[indexer] * weights, axis=axis) / sumval

因此,在最后一行中,该列表

indexer
用于slice
sorted

In [81]: x = np.arange(12).reshape(3,4)In [83]: indexer = [slice(None), slice(None,2)]In [84]: x[indexer]/usr/local/bin/ipython3:1: FutureWarning: Using a non-tuple sequence for multidimensional indexing is deprecated; use `arr[tuple(seq)]` instead of `arr[seq]`. In the future this will be interpreted as an array index, `arr[np.array(seq)]`, which will result either in an error or a different result.  #!/usr/bin/python3Out[84]: array([[0, 1],       [4, 5],       [8, 9]])In [85]: x[tuple(indexer)]Out[85]: array([[0, 1],       [4, 5],       [8, 9]])

使用切片列表是可行的,但是计划将来会贬值。涉及多个维度的索引应该是元组。在上下文中使用列表是一种较旧的样式,正在逐步淘汰。

因此,

scipy
开发人员需要解决此问题。这不是最终用户应该处理的事情。但是目前,不用担心
futurewarning
。它不影响计算或绘图。有一种方法可以抑制将来的警告,但是我不知道这是不是可以立即使用的。

FutureWarning:不建议使用非元组序列进行多维索引编制,而应使用

arr [tuple(seq)]
而非
arr[seq]



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/639093.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号