I have symbols defined as follows:
import sympy
class construct(object):
def __init__(self, value):
self.value = value
def __add__(self, symbol):
return construct(self.value+symbol.value)
def __mul__(self,symbol):
return construct(self.value*symbol.value)
a = construct(2)
b = construct(10)
(the above code is runnable). Now, when I try to put them in a sympy
matrix, it raises an error and I can't figure out why:
import sympy
A= sympy.Matrix([[a],[b]])
....SympifyError: Sympify of expression 'could not parse u'<__main__.construct object at 0x1088a5ad0>'' failed, because of exception being raised:
SyntaxError: invalid syntax (<string>, line 1)
I'm not even using strings here at all, so I'm not sure why it's complaining about a parse error.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…