您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

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

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/python3
Out[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]

其他 2022/1/1 18:25:16 有421人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶