使用零((n,n)时)Sympy“不是在字符串格式化期间转换的所有参数”

时间:2021-10-04 20:24:31

I am running sympy on an external computer, but when I do the simple command

我在外部计算机上运行同情,但是当我执行简单命令时

M=sympy.zeros((2,2))

I get the error

我收到了错误

 Traceback (most recent call last):
  File "test.py", line 8, in <module>
    M=sp.zeros((2,2))
  File "/apps/brussel/magnycours/software/sympy/0.7.6-intel-2015a-Python-2.7.9/lib/python2.7/site-packages/sympy/matrices/dense.py", line 1229, in zeros
    return cls.zeros(r, c)
  File "/apps/brussel/magnycours/software/sympy/0.7.6-intel-2015a-Python-2.7.9/lib/python2.7/site-packages/sympy/matrices/dense.py", line 513, in zeros
    r = as_int(r)
  File "/apps/brussel/magnycours/software/sympy/0.7.6-intel-2015a-Python-2.7.9/lib/python2.7/site-packages/sympy/core/compatibility.py", line 389, in as_int
    raise ValueError('%s is not an integer' % n)
TypeError: not all arguments converted during string formatting

However, when I run it on my own computer, there is no problem. How can I fix this?

但是,当我在自己的计算机上运行它时,没有问题。我怎样才能解决这个问题?

The version on my computer is 0.7.1.rc1, while the one on the cluster is 0.7.6. Should I ask them to install the (older?) version or is there an easier fix??

我的计算机上的版本是0.7.1.rc1,而群集上的版本是0.7.6。我应该要求他们安装(较旧的?)版本还是更容易修复?

1 个解决方案

#1


0  

If you want a 2x2 matrix with zeros, try this:

如果你想要一个带零的2x2矩阵,试试这个:

In [6]: zeros(2,2)
Out[6]: 
Matrix([
[0, 0],
[0, 0]])

or

要么

In [7]: zeros(2)
Out[7]: 
Matrix([
[0, 0],
[0, 0]])

#1


0  

If you want a 2x2 matrix with zeros, try this:

如果你想要一个带零的2x2矩阵,试试这个:

In [6]: zeros(2,2)
Out[6]: 
Matrix([
[0, 0],
[0, 0]])

or

要么

In [7]: zeros(2)
Out[7]: 
Matrix([
[0, 0],
[0, 0]])