ENH: Add support for ipython latex printing to polynomial#11528
ENH: Add support for ipython latex printing to polynomial#11528charris merged 1 commit intonumpy:masterfrom
Conversation
eric-wieser
left a comment
There was a problem hiding this comment.
Shown with some mathjax renderings
|
I think we may want to revisit 3., especially as the terms extend to higher powers and the mapping That said, this PR looks like a good starting point that will generate useful feedback. |
Yes, I agree - that was the choice I was least sure of. Shall I do 0, 1, or both of the following?
Do you think we should gain most of the feedback before or after merging? It's not clear to me how best to run |
numpy/polynomial/_polybase.py
Outdated
There was a problem hiding this comment.
Unfortunately '{}'.format(some_float) doesn't generate valid latex for coefficients using scientific notation. I'm not sure what the best thing to do here is - do we show the coefficients as monospaced and keep the e, to make it easy to copy/paste them?
There was a problem hiding this comment.
do we show the coefficients as monospaced and keep the e, to make it easy to copy/paste them?
Makes sense, at least in the near term. This might be one of the things that garners feedback. We should probably decide how to set various options for the display, but that can wait.
Do you think we should gain most of the feedback before or after merging?
I was thinking after merge. I don't think it matters much if we change things later, and we won't know what people want in practice until we have people using it :) Maybe mark it as experimental in the release notes. Can make it a highlight just so folks see it.
There was a problem hiding this comment.
Yes, this part of latex formatting is annoying; we have a specific method that does it for units/quantities
|
For those following along and wondering what this does, ipython front-ends can call "rich display" methods to display a class object. |
|
A big +1 for this from the peanut gallery. |
|
Needs a release note. |
36ca790 to
1457b53
Compare
Choices made, and the alternatives rejected (for no particularly strong reason): 1. Show terms in ascending order, to match their internal representation * alternative: descending, to match convention 2. Shows 0 terms in gray * alternative: omit entirely * alternative: show normally to aid comparison 3. Write each term as `basis(ax + b) * alternative: write as `basis(u) ... where u = ax + b` * alternative: show the normalized polynomial In future it would perhaps make sense to expose these options to the end user
1457b53 to
e6e60c0
Compare
Codecov Report
@@ Coverage Diff @@
## master #11528 +/- ##
==========================================
- Coverage 86.58% 85.95% -0.64%
==========================================
Files 315 326 +11
Lines 81307 81990 +683
==========================================
+ Hits 70401 70474 +73
- Misses 10906 11516 +610
Continue to review full report at Codecov.
|
|
Seems users can toggle pretty printing with |
|
The sad reality might be that almost no one uses |
|
I do use it... |



Choices made, and the alternatives rejected (for no particularly strong reason):
basis(u) ... where u = ax + bIn future it would perhaps make sense to expose these options to the end user