Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solve: Normalize the output format for one or multiples solutions. #11665

Open
latot opened this issue Sep 26, 2016 · 3 comments
Open

Solve: Normalize the output format for one or multiples solutions. #11665

latot opened this issue Sep 26, 2016 · 3 comments

Comments

@latot
Copy link
Contributor

latot commented Sep 26, 2016

Hi, basically the title, examples:

>>> solve([Eq(y+x,1), Eq(x-y, 1)])
{x: 1, y: 0}
>>> solve(Eq(2*x,1))
[1/2]

ideal to:

>>> solve([Eq(y+x,1), Eq(x-y, 1)])
{x: 1, y: 0}
>>> solve(Eq(2*x,1))
{x: 1/2}

Thx. Cya.

@Shekharrajak
Copy link
Member

You can set dict=true

In [1]: solve(Eq(2*x,1), dict=true)
Out[1]: [{x: 1/2}]

In [2]: solve([Eq(y+x,1), Eq(x-y, 1)], dict=true)
Out[2]: [{x: 1, y: 0}]

@Shekharrajak
Copy link
Member

solveset

In [23]: solveset(Eq(2*x,1))
Out[23]: {1/2} 

In [24]: nonlinsolve([Eq(y+x,1), Eq(x-y, 1)], [x, y])
Out[24]: {(1, 0)}

In [25]: nonlinsolve([Eq(y+x,1), Eq(x-y, 1)], [y, x])
Out[25]: {(0, 1)}  # always FiniteSet of tuple(s) 

@latot
Copy link
Contributor Author

latot commented Sep 27, 2016

Hi, this is only examples, and the idea its can set more than one eq, when solveset support it i think it will be fine, this examples don't are restricted for linear systems.

The focus here its, don't play with the output, choose one type of output and respect it, its very umconfortable start handle this manually, think when we use this for some work we use this automatically, so normally we can't control the input eqs and the requested vars, so play with the output its a bad idea.

i know use dict or set, but i think have a normal return should choose some standard format.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants