-
-
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
expint/polylog: unicode print subscripts in more cases #25599
Conversation
Earlier pretty printing did not work for expint(s, z) but worked for E₃(z). Added _opportunistic_subscripter function to pretty_symbology.py It checks whether all characters of the argument are subscriptable. addresses issue sympy#25312 prints Eₛ(z) instead of expint(s, z)
✅ Hi, I am the SymPy bot. 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.13. Click here to see the pull request description that was parsed.
Update The release notes on the wiki have been updated. |
sympy/printing/pretty/pretty.py
Outdated
@@ -1811,7 +1811,7 @@ def _print_DiracDelta(self, e): | |||
return self._print_Function(e) | |||
|
|||
def _print_expint(self, e): | |||
if e.args[0].is_Integer and self._use_unicode: | |||
if _opportunistic_subscripter(self._print(e.args[0])) and self._use_unicode: | |||
return self._print_Function(Function('E_%s' % e.args[0])(e.args[1])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Following up a bit on @sylee957's comment... We need to be careful here: you can't ask permission about the _print(args[0])
but then use the the non-printed args[0]
.
Probably we can think of several fixes...
Alternatively: "zen of python" says "better to ask forgiveness than permission". So another possibility is to code it in a way that this possibility is avoided?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also did write a fix for this ! (just forgot to comment it here)
Defined a variable called subscript
that is used by both is_subscriptable_in_unicode()
and self._print_Function
Renamed _opportunistic_subscripter to is_subscriptable_in_unicode Changed order of tests to slightly improve performance Added docstring for is_subscriptable_in_unicode Renamed test function for consistency with other functions Uses _print(e.args[0]) instead of non-printed e.args[0]
Hey, just checking is there something more to be done? (Or something I did wrong) |
changed _print_expint and _print_polylog to help pretty print.
Added _opportunistic_subscripter function for the same
References to other Issues or PRs
Fixes #25312
Brief description of what is fixed or changed
Earlier printing expint & polylog functions with two symbols such as expint(s, z) did not subscript but now does as Eₛ(z)
Other comments
Release Notes