I`m creating a script in Python Sympy library and trying to access the result returned by solveset() and linsolve() functions. My problem is that the object returned by these functions is of type finiteset and I want to select some results automaticaly to re-enter it in other equations. Any body could help me?
An example: I create a list of equations with two unknown variables:
>>> a1, a2 = symbols('a1, a2') >>> eq2_1 = Eq(-3*a1/10 - 3*a2/20 + 1/12) >>> eq2_2 = Eq(-3*a1/20 - 13*a2/105 + 1/20) >>> lista = [eq2_1,eq2_2] >>> str(lista) [-3*a1/10 - 3*a2/20 + 1/12, -3*a1/20 - 13*a2/105 + 1/20]
Then a solve it with the linsolve() method.
>>> a = linsolve(lista,a1,a2) >>> a {(71/369, 7/41)}
The result is correct, but I'm unable to get these results in to a variable.
O tried dics, lists, tuples, indexing commands, but always return the error. "Finiteset objects has no attribute 'command'"
I found the sympy library way in this link http://docs.sympy.org/latest/tutorial/manipulation.html
Use .args atribute in the function or result object. If I have a function:
>>>func = Eq(u(x),−x+sin(x)) >>>func u(x) = -x + sin(x) >>>func.args[0] u(x) >>>func.args[1] -x+sin(x)
The same applies for a result that is a finite set type.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With