【发布时间】:2019-10-02 10:45:44
【问题描述】:
我将 python 代码用作我不想触摸的黑匣子。该代码在 Ubuntu 12.04 下使用 Python 运行良好,但在将系统升级到 Ubuntu 16 后,我收到以下警告,该警告会中断代码运行。知道如何在不更改代码的情况下解决此问题吗?非常感谢。
文件“/home/hammouc/.local/lib/python2.7/site-packages/scipy/sparse/base.py”,第 849 行,以致密 return np.asmatrix(self.toarray(order=order, out=out))
文件“/home/hammouc/.local/lib/python2.7/site-packages/numpy/matrixlib/defmatrix.py”,第 71 行,在 asmatrix 中 返回矩阵(数据,dtype=dtype,copy=False)
新中的文件“/home/hammouc/.local/lib/python2.7/site-packages/numpy/matrixlib/defmatrix.py”,第 123 行 PendingDeprecationWarning, stacklevel=2)
PendingDeprecationWarning:矩阵子类不是表示矩阵或处理线性代数的推荐方法(请参阅https://docs.scipy.org/doc/numpy/user/numpy-for-matlab-users.html)。请调整您的代码以使用常规 ndarray。
【问题讨论】:
-
看起来像一个 scipy.sparse 矩阵
todense正在触发这个。理想的情况是用toarray方法调用替换它。 -
非常感谢这有帮助!
-
您使用的是哪个
numpy和scipy版本?我知道我们不鼓励使用np.matrix,但我不知道有任何实际的弃用趋势。 -
我在 np.matrixlib.defmatrix.py 文件 (1.16.3) 中发现了该警告消息。您的警告级别必须与我的不同(默认)。
标签: python-2.7 numpy matrix scipy deprecated