python - 获取同情矩阵的形状
问题描述
我想知道用于调试目的的 sympy 矩阵的形状。该文档建议以下内容:
from sympy import shape
M = Matrix([[1, 2, 3], [-2, 0, 4]])
shape(M)
然而,这似乎不适用于我的 sympy 版本,甚至在集成到 sympy 文档网站的 life shell 中也不起作用。
在docs.sympy.org的 life shell 中,它会引发以下错误:
>>> from sympy import shape
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: cannot import name shape
任何帮助,将不胜感激。谢谢你。
解决方案
尝试这个
import sympy
M = sympy.Matrix([[1, 2, 3], [-2, 0, 4]])
M.shape
我明白了
(2, 3)
推荐阅读
- r - groupby 多列然后求和然后在 dplyr 中求和
- prestashop - Prestashop 1.7 只需要包含税费,不包含在产品价格中
- linux - 我有 AWS SAM local 0.2.11,但无法将其升级到 0.3.0。升级没有发生
- vue.js - 您将如何处理 Vue 应用程序中的不同主题?
- typescript - 使用嵌套的泛型参数定义类型别名
- pycharm - 停止 PyCharm 将选定文本自动插入到搜索框
- python - subprocess.Popen 错误:不可迭代
- html - 为 Swift NSAttributedString 更改无序列表的字体
- python - 使用列表生成字典
- r - 拥塞的日期时间x轴ggplot2