为什么SymPy不喜欢重新定义变量?

时间:2019-10-30 12:47:27

标签: python numpy simpy

我在SymPy Live上参加了这次会议:

Python console for SymPy 1.4 (Python 2.7.12)

These commands were executed:
>>> from __future__ import division
>>> from sympy import *
>>> x, y, z, t = symbols('x y z t')
>>> k, m, n = symbols('k m n', integer=True)
>>> f, g, h = symbols('f g h', cls=Function)

Warning: this shell runs with SymPy 1.4 and so examples pulled from
other documentation may provide unexpected results.
Documentation can be found at http://docs.sympy.org/1.4.

>>> import numpy as np
>>> V = np.array([[1, y, x, 1], [y, 1, z, 1], [x, z, 1, 1]])
>>> V = np.array([[1, y, x, 1], [y, 1, z, 1], [x, z, 1, 1]])
Exception in SymPy Live of type 
<type 'exceptions.ValueError'>
for reference the last 5 stack trace entries are
Traceback (most recent call last):
  File "/base/data/home/apps/s~sympy-live-hrd/57.417397408462217066/shell.py", line 781, in post
    live.evaluate(statement, session, printer, stream)
  File "/base/data/home/apps/s~sympy-live-hrd/57.417397408462217066/shell.py", line 453, in evaluate
    if name not in old_globals or val != old_globals[name]:
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

V的第二次分配与第一次相同,但是第二次SymPy引发异常。

我做错什么了吗?如果是,我错过了文档的哪一部分?

0 个答案:

没有答案