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
Allow subclasses of sympy objects to override _repr_latex_
#19944
Conversation
✅ Hi, I am the SymPy bot (v160). 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. |
_repr_latex_
_repr_latex_
5690f54
to
8c35e91
Compare
Codecov Report
@@ Coverage Diff @@
## master #19944 +/- ##
=============================================
+ Coverage 75.778% 75.803% +0.024%
=============================================
Files 668 668
Lines 173216 173193 -23
Branches 40837 40842 +5
=============================================
+ Hits 131261 131286 +25
+ Misses 36221 36173 -48
Partials 5734 5734 |
Looks good to me |
Might come back and add an xref to the upstream ipython issue tomorrow. |
3043b74
to
1ea5f30
Compare
The previous behavior was to completely ignore this hook once `init_printing` had been called, which was surprising to the user.
1ea5f30
to
92d8e58
Compare
Changed the implementation to be a bit more verbose but hopefully easier to understand - probably needs re-reviewing |
Looks good |
The previous behavior was to completely ignore this hook once
init_printing
had been called, which was surprising to the user.References to other Issues or PRs
This fixes an issue related to #10062, but only for subclasses of sympy types.
Brief description of what is fixed or changed
init_printing()
no longer causes_repr_latex_
methods defined onPrintable
subclasses to be completely ignored. The rules in IPython for looking up magic methods are currently (ipython/ipython#8938):But would make more sense as:
Since this probably won't change any time soon, the workaround is to register printers for
Printable
via methods not explicit hooks - this allows users to override them if they so wish.Other comments
Release Notes
_repr_latex_
,_repr_svg_
, and_repr_png_
methods of subclasses of sympy objects are no longer discarded wheninit_printing()
is called.