【问题标题】:FutureWarning: Using a non-tuple sequence for multidimensional indexing is deprecatedFutureWarning:不推荐使用非元组序列进行多维索引
【发布时间】:2021-05-29 16:31:27
【问题描述】:

我收到以下 FutureWarning:

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.
  self.commission_matrix[np.meshgrid(indexes, indexes, indexing='ij', sparse=True)] = self.trading_fee[

我该如何制定

    for exc_name in self.exchanges.keys():
        indexes = [index for cur_name, index in self.currency2index.items() if exc_name in cur_name]
        self.commission_matrix[np.meshgrid(indexes, indexes, indexing='ij', sparse=True)] = self.trading_fee[
            exc_name]

这样它就可以避免这个错误?我使用 pychem,没有其他关于此 FutureWarning 的主题可以帮助我。 FutureWarning 不会影响我的结果,但我想知道如何绕过此警告。 非常感谢

【问题讨论】:

标签: python


【解决方案1】:

我相信这会消除警告:

   for exc_name in self.exchanges.keys():
        indexes = [index for cur_name, index in self.currency2index.items() if exc_name in cur_name]
        self.commission_matrix[tuple(np.meshgrid(indexes, indexes, indexing='ij', sparse=True))] = self.trading_fee[
            exc_name]

【讨论】:

    猜你喜欢
    • 2019-04-14
    • 2019-03-06
    • 2019-03-19
    • 2019-02-06
    • 2021-03-02
    • 2019-08-24
    • 2019-10-27
    • 2019-02-07
    • 2023-01-10
    相关资源
    最近更新 更多