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
physics.quantum: Respect local printer settings in _sympystr
.
#19424
physics.quantum: Respect local printer settings in _sympystr
.
#19424
Conversation
Calling `sstr`, `str`, or `"%s" %` inside `_sympystr` discards local printer settings and uses the global ones. It also means subclasses of `sympy.printing.str.StrPrinter` are ignored.
✅ Hi, I am the SymPy bot (v158). 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.7. Note: This comment will be updated with the latest check if you edit the pull request. You need to reload the page to see it. Click here to see the pull request description that was parsed.
Update The release notes on the wiki have been updated. |
_sympystr
._sympystr
.
Codecov Report
@@ Coverage Diff @@
## master #19424 +/- ##
=============================================
+ Coverage 75.611% 75.618% +0.007%
=============================================
Files 652 652
Lines 169634 169684 +50
Branches 40032 40049 +17
=============================================
+ Hits 128263 128313 +50
- Misses 35758 35760 +2
+ Partials 5613 5611 -2 |
Are there any examples where the output is changed as a result of these changes? |
Yes, any call of |
Can you give an example (in code)? I often look at the added tests as a starting point to understand the effect of the changes in a PR. This doesn't add or change any tests though. |
This is one of those cases where it's a lot easier to see that the logic is wrong than it is to construct the corner case when it matters. Here's the one I came up with: from sympy import symbols, sstr
from sympy.physics.quantum import AntiCommutator
from sympy.physics.quantum import Operator
x, y = symbols('x,y')
A = Operator('A')
B = Operator('B')
sstr(AntiCommutator(A, B + 1.0), full_prec=True)
# before: '{1.0 + B,AA}'
# after: '{1.00000000000000 + B,AA}' |
Okay, thanks. I would suggest adding that as a test but I'm not sure if the object makes sense mathematically. |
Calling
sstr
,str
, or"%s" %
inside_sympystr
discards local printer settings and uses the global ones.It also means subclasses of
sympy.printing.str.StrPrinter
are ignored.References to other Issues or PRs
Brief description of what is fixed or changed
Other comments
Release Notes
Commutator
,Anticommutator
,InnerProduct
,TensorProduct
, andOuterProduct
now respect keyword-arguments tosstr
.