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 raises error on duplicate symbols #23891
Conversation
✅ Hi, I am the SymPy bot (v167). I'm here to help you write a release notes entry. Please read the guide on how to write release notes. Your release notes are in good order. Here is what the release notes will look like:
This will be added to https://github.com/sympy/sympy/wiki/Release-Notes-for-1.12. Click here to see the pull request description that was parsed.
Update The release notes on the wiki have been updated. |
d989bb9
to
bb46521
Compare
Benchmark results from GitHub Actions Lower numbers are good, higher numbers are bad. A ratio less than 1 Significantly changed benchmark results (PR vs master) Significantly changed benchmark results (master vs previous release) before after ratio
[ac3b08a6] [3d85b8bd]
- 1.23±0.03ms 747±20μs 0.61 solve.TimeSparseSystem.time_linear_eq_to_matrix(10)
- 3.52±0.06ms 1.41±0.03ms 0.40 solve.TimeSparseSystem.time_linear_eq_to_matrix(20)
- 7.09±0.06ms 2.07±0.03ms 0.29 solve.TimeSparseSystem.time_linear_eq_to_matrix(30)
Full benchmark results can be found as artifacts in GitHub Actions |
This doesn't catch the case of duplicated symbols when the input is not a list: In [4]: solve(x, x, y, x)
Out[4]: [{x: 0}, {x: 0}]
In [5]: solve([x], x, y, x)
---------------------------------------------------------------------------
GeneratorsError |
Thanks for the catch, @oscarbenjamin. This is ready to go. |
Looks good! |
References to other Issues or PRs
Brief description of what is fixed or changed
Rather than deal in some unique way with a solve request that contains duplicate symbols, the presence of duplicates now raises an error. This seems like a good idea because there is no reason to include duplicates and it might indicate a typo of the person entering the request. Disallowing duplicates matches the behvior of
nonlinsolve
andlinsolve
Other comments
There are lots of stray extra lines fixed in the first commit. Please review commits starting at 2 instead of looking at "Files changed" if that much noise is bothersome.
Release Notes
solve
now raises an error if duplicate symbols are given in the unknowns to be solved for such assolve(equations, [x, y, x])
.