-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Make ShapeError more readable #24161
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. |
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
[41d90958] [7a4b4125]
<sympy-1.11.1^0>
- 999±2μs 633±2μs 0.63 solve.TimeSparseSystem.time_linear_eq_to_matrix(10)
- 2.84±0.01ms 1.18±0ms 0.41 solve.TimeSparseSystem.time_linear_eq_to_matrix(20)
- 5.65±0.01ms 1.72±0ms 0.30 solve.TimeSparseSystem.time_linear_eq_to_matrix(30)
Full benchmark results can be found as artifacts in GitHub Actions |
Looks good. |
In general you should avoid putting the string form of arbitrary expressions inside of error messages. The expression could be arbitrary large, meaning the exception itself might take a long time to compute, and a very large matrix in an error message isn't very readable anyway. I've thought about ways that we can include expressions inside of exception objects in ways that are easier to inspect but that don't require computing |
Ideally all exceptions raised would be custom exception classes that subclass a something like SymPyError and then it should be usable with delayed formatting like the logging module e.g.:
Then |
References to other Issues or PRs
Fixes #24160
Brief description of what is fixed or changed
I have replaced all occurrences of
ShapeError
and there are only four of these that have the problem.I had to pick whether it is a good option to print out the full variables or not,
But I recently found that users are allowed to use other frameworks to inspect local variables (https://stackoverflow.com/questions/19514288/locals-and-globals-in-stack-trace-on-exception-python)
And it is automatically done in like pdb, pytest, ..., so there wouldn't be a need to print out full Matrix object at all.
Other comments
Release Notes
ShapeError
messages more readable for users.