GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Fix over/under mathtext symbols by aitikgupta · Pull Request #19314 · matplotlib/matplotlib

Conversation

@aitikgupta

@aitikgupta aitikgupta commented Jan 18, 2021

Copy link
Copy Markdown
Contributor

PR Summary

This PR fixes the alignment issues with the current overunder symbols in mathtext.

Brief summary of the proposal:

(This rewrites the following IDs of the tests):

baselines_to_rewrite = [18, 22, 29, 34, 52, 67]

Closes #19178

PR Checklist

  • Has pytest style unit tests (and pytest passes).
  • Is Flake 8 compliant (run flake8 on changed files to check).
  • New features are documented, with examples if plot related.
  • Documentation is sphinx and numpydoc compliant (the docs should build without error).
  • Conforms to Matplotlib style conventions (install flake8-docstrings and run flake8 --docstring-convention=all).
  • New features have an entry in doc/users/next_whats_new/ (follow instructions in README.rst there).
  • API changes documented in doc/api/next_api_changes/ (follow instructions in README.rst there).

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
aitikgupta added 2 commits January 18, 2021 09:06
@aitikgupta
Typo fix: integral is not a over/under symbol
99492fa
@aitikgupta
Fixed overunder symbols' alignments
37d022c
@aitikgupta

aitikgupta commented Jan 18, 2021 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

Some tests other than mathtext also use these symbols, for example:

lib/matplotlib/tests/test_text.py::test_multiline2:

The diff is as expected:

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@anntzer

anntzer commented Jan 18, 2021

Copy link
Copy Markdown
Contributor

I am confused as to why the mathfont tests (which do not involve subsuper) have baseline changes? (perhaps I'm missing something obvious...)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@QuLogic

QuLogic commented Jan 19, 2021

Copy link
Copy Markdown
Member

It looks like maybe you updated mathfont_* when only mathtext_* were necessary? Also, maybe 18 doesn't need an update, but it's hard to tell from the GitHub diff only.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@aitikgupta

aitikgupta commented Jan 19, 2021 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

There's a good reason to believe 18 shouldn't be updated, but I think the global positioning inside svg is changing?
This is the failed diff:

(And yes, my bad, I just used the IDs of the baselines - so it included mathtext_* and mathfont_*)
Thanks for pointing it out @anntzer @QuLogic :)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@aitikgupta
aitikgupta force-pushed the overunder-alignment branch from 1f5fb57 to 78d37a9 Compare January 19, 2021 03:54
@QuLogic

QuLogic commented Jan 19, 2021

Copy link
Copy Markdown
Member

Yes, I can see that 18 needs updates in some places but not all of them. Try using tools/triage_tests.py to see what ones really need updates.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@aitikgupta

aitikgupta commented Jan 20, 2021 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

some places but not all of them

That's right, and it was deliberate - for 18 only these fail (6 out of 15 variants):

18-pdf-mathtext-cm
18-pdf-mathtext-dejavuserif
18-pdf-mathtext-stix
18-svg-mathtext-stix
18-svg-mathtext-stixsans

For IDs like 22 or 67, (15 out of 15 fail):

67-pdf-mathtext-cm
67-pdf-mathtext-dejavusans
67-pdf-mathtext-dejavuserif
67-pdf-mathtext-stix
67-pdf-mathtext-stixsans
67-png-mathtext-cm
67-png-mathtext-dejavusans
67-png-mathtext-dejavuserif
67-png-mathtext-stix
67-png-mathtext-stixsans
67-svg-mathtext-cm
67-svg-mathtext-dejavusans
67-svg-mathtext-dejavuserif
67-svg-mathtext-stix
67-svg-mathtext-stixsans

I believe we're comparing images with a tolerance?
Which is why I thought it's better to update all variants for IDs like 18.

We could change just the failing images and forget about the IDs, it should not raise an error. Should I update the PR?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@QuLogic

QuLogic commented Jan 20, 2021

Copy link
Copy Markdown
Member

I believe we're comparing images with a tolerance?

No, the default tolerance is 0, and I don't see the mathtext tests setting anything different.

We could change just the failing images and forget about the IDs, it should not raise an error. Should I update the PR?

Yes, better to reduce test image churn when there is no failure necessitating an update.

aitikgupta reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@aitikgupta
aitikgupta force-pushed the overunder-alignment branch from 78d37a9 to d8466c1 Compare January 20, 2021 11:07
@aitikgupta

aitikgupta commented Jan 20, 2021 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

With the latest push only 67 failing mathtext images are updated, regardless of their IDs.

The failing mathtext images:
to_rewrite = [
  "mathtext_cm_18.pdf",
  "mathtext_dejavuserif_18.pdf",
  "mathtext_stix_18.pdf",
  "mathtext_stix_18.svg",
  "mathtext_stixsans_18.svg",
  "mathtext_cm_22.pdf",
  "mathtext_dejavusans_22.pdf",
  "mathtext_dejavuserif_22.pdf",
  "mathtext_stix_22.pdf",
  "mathtext_stixsans_22.pdf",
  "mathtext_cm_22.png",
  "mathtext_dejavusans_22.png",
  "mathtext_dejavuserif_22.png",
  "mathtext_stix_22.png",
  "mathtext_stixsans_22.png",
  "mathtext_cm_22.svg",
  "mathtext_dejavusans_22.svg",
  "mathtext_dejavuserif_22.svg",
  "mathtext_stix_22.svg",
  "mathtext_stixsans_22.svg",
  "mathtext_dejavuserif_29.pdf",
  "mathtext_dejavusans_29.svg",
  "mathtext_cm_34.pdf",
  "mathtext_dejavusans_34.pdf",
  "mathtext_dejavuserif_34.pdf",
  "mathtext_stix_34.pdf",
  "mathtext_stixsans_34.pdf",
  "mathtext_cm_34.png",
  "mathtext_dejavusans_34.png",
  "mathtext_dejavuserif_34.png",
  "mathtext_stix_34.png",
  "mathtext_stixsans_34.png",
  "mathtext_cm_34.svg",
  "mathtext_dejavusans_34.svg",
  "mathtext_dejavuserif_34.svg",
  "mathtext_stix_34.svg",
  "mathtext_stixsans_34.svg",
  "mathtext_cm_52.pdf",
  "mathtext_dejavusans_52.pdf",
  "mathtext_dejavuserif_52.pdf",
  "mathtext_stix_52.pdf",
  "mathtext_stixsans_52.pdf",
  "mathtext_cm_52.png",
  "mathtext_dejavusans_52.png",
  "mathtext_dejavuserif_52.png",
  "mathtext_stix_52.png",
  "mathtext_stixsans_52.png",
  "mathtext_cm_52.svg",
  "mathtext_dejavusans_52.svg",
  "mathtext_dejavuserif_52.svg",
  "mathtext_stix_52.svg",
  "mathtext_stixsans_52.svg",
  "mathtext_cm_67.pdf",
  "mathtext_dejavusans_67.pdf",
  "mathtext_dejavuserif_67.pdf",
  "mathtext_stix_67.pdf",
  "mathtext_stixsans_67.pdf",
  "mathtext_cm_67.png",
  "mathtext_dejavusans_67.png",
  "mathtext_dejavuserif_67.png",
  "mathtext_stix_67.png",
  "mathtext_stixsans_67.png",
  "mathtext_cm_67.svg",
  "mathtext_dejavusans_67.svg",
  "mathtext_dejavuserif_67.svg",
  "mathtext_stix_67.svg",
  "mathtext_stixsans_67.svg"
  ]
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

QuLogic
QuLogic approved these changes Jan 22, 2021
View reviewed changes
@QuLogic QuLogic added the topic: text/mathtext label Jan 22, 2021
@aitikgupta

aitikgupta commented Feb 4, 2021 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

I think this is supposed to go with the 3.4 release @QuLogic
Right @anntzer?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@QuLogic

QuLogic commented Feb 4, 2021

Copy link
Copy Markdown
Member

It would need a second review.

aitikgupta reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@QuLogic QuLogic added this to the v3.4.0 milestone Feb 4, 2021
@anntzer anntzer self-assigned this Feb 5, 2021
@anntzer

anntzer commented Feb 6, 2021

Copy link
Copy Markdown
Contributor

Just a few points regarding the baseline images changes:

  • I would just delete test 18, because the math expression is strictly included in the expression of test 22.
  • I would group the changed tests together into single expressions (resulting in a single test image), because not having to repeatedly embed the glyphs in each of the pdf/svg files results in significant savings. IOW, the following patch
diff --git i/lib/matplotlib/tests/test_mathtext.py w/lib/matplotlib/tests/test_mathtext.py
index 16ac7c7ba..b5fd906d2 100644
--- i/lib/matplotlib/tests/test_mathtext.py
+++ w/lib/matplotlib/tests/test_mathtext.py
@@ -31,11 +31,13 @@ math_tests = [
     r'$x^2$',
     r'$x^2_y$',
     r'$x_y^2$',
-    r'$\prod_{i=\alpha_{i+1}}^\infty$',
+    (r'$\sum _{\genfrac{}{}{0}{}{0\leq i\leq m}{0<j<n}}f\left(i,j\right)'
+     r'\mathcal{R}\prod_{i=\alpha_{i+1}}^\infty a_i \sin(2 \pi f x_i)'
+     r"\sqrt[2]{\prod^\frac{x}{2\pi^2}_\infty}$"),
     r'$x = \frac{x+\frac{5}{2}}{\frac{y+3}{8}}$',
     r'$dz/dt = \gamma x^2 + {\rm sin}(2\pi y+\phi)$',
     r'Foo: $\alpha_{i+1}^j = {\rm sin}(2\pi f_j t_i) e^{-5 t_i/\tau}$',
-    r'$\mathcal{R}\prod_{i=\alpha_{i+1}}^\infty a_i \sin(2 \pi f x_i)$',
+    None,
     r'Variable $i$ is good',
     r'$\Delta_i^j$',
     r'$\Delta^j_{i+1}$',
@@ -47,7 +49,7 @@ math_tests = [
     r"$f'\quad f'''(x)\quad ''/\mathrm{yr}$",
     r'$\frac{x_2888}{y}$',
     r"$\sqrt[3]{\frac{X_2}{Y}}=5$",
-    r"$\sqrt[5]{\prod^\frac{x}{2\pi^2}_\infty}$",
+    None,
     r"$\sqrt[3]{x}=5$",
     r'$\frac{X}{\frac{X}{Y}}$',
     r"$W^{3\beta}_{\delta_1 \rho_1 \sigma_2} = U^{3\beta}_{\delta_1 \rho_1} + \frac{1}{8 \pi 2} \int^{\alpha_2}_{\alpha_2} d \alpha^\prime_2 \left[\frac{ U^{2\beta}_{\delta_1 \rho_1} - \alpha^\prime_2U^{1\beta}_{\rho_1 \sigma_2} }{U^{0\beta}_{\rho_1 \sigma_2}}\right]$",
@@ -89,11 +91,13 @@ math_tests = [
     r'${x}_{92}^{31415}+\pi $',
     r'${x}_{{y}_{b}^{a}}^{{z}_{c}^{d}}$',
     r'${y}_{3}^{\prime \prime \prime }$',
+    # End of the MathML torture tests.
+
     r"$\left( \xi \left( 1 - \xi \right) \right)$",  # Bug 2969451
     r"$\left(2 \, a=b\right)$",  # Sage bug #8125
     r"$? ! &$",  # github issue #466
     None,
-    r'$\sum _{\genfrac{}{}{0}{}{0\leq i\leq m}{0<j<n}}P\left(i,j\right)$',
+    None,
     r"$\left\Vert a \right\Vert \left\vert b \right\vert \left| a \right| \left\| b\right\| \Vert a \Vert \vert b \vert$",
     r'$\mathring{A}  \AA$',
     r'$M \, M \thinspace M \/ M \> M \: M \; M \ M \enspace M \quad M \qquad M \! M$',

(together with updating image 18 for the new test) shrinks the overall size of the new baselines from 508K to 256K, a not insignificant saving. (I explicitly left test 52 alone as we can reasonably leave the "mathml torture test" as is; I also slightly tweaked the mathtext expression to reduce the number of independent glyphs used.)

aitikgupta reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@aitikgupta

aitikgupta commented Feb 7, 2021

Copy link
Copy Markdown
Contributor Author

I notice something interesting:
Following two are png and svg outputs of test 52 dejavusans font.
Note how the b character is shifted, as well as the bottom i, j, k characters in the png vs svg output.

image
image

(side by side)

Maybe it's hard to notice here, but there is definitely something fishy w.r.t. png vs svg backend?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

aitikgupta added 3 commits February 7, 2021 18:35
@aitikgupta
Merge some mathtext tests
b0dbead
@aitikgupta
Update baseline images for mathtext
9b2e85c
@aitikgupta
Update baseline images for other tests
b74db71
@aitikgupta
aitikgupta force-pushed the overunder-alignment branch from d8466c1 to b74db71 Compare February 7, 2021 13:06
@anntzer

anntzer commented Feb 7, 2021 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Without looking carefully at this, it may be related to #19261 (comment) / #5414? (If so, this may change depending on rcParams["text.hinting"].)

aitikgupta reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@QuLogic

QuLogic commented Feb 9, 2021

Copy link
Copy Markdown
Member

You will need to rebase if you want to fix the docs CI build. @anntzer is there anything else left to do here?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

anntzer
anntzer approved these changes Feb 9, 2021
View reviewed changes
@anntzer

anntzer commented Feb 9, 2021 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Nope, lgtm.
@QuLogic did you want docs to build?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@QuLogic

QuLogic commented Feb 10, 2021

Copy link
Copy Markdown
Member

No, it doesn't look like this has any relevant doc changes.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@QuLogic
QuLogic merged commit 8ff6e8a into matplotlib:master Feb 10, 2021
@aitikgupta
aitikgupta deleted the overunder-alignment branch February 10, 2021 06:04
tacaswell added a commit to tacaswell/matplotlib that referenced this pull request Jun 15, 2023
@tacaswell
MNT: remove test images from mathtext tests that have been removed
2f89bc0
b0dbead via matplotlib#19314 several tests
were merged but the images for them were not removed.
@tacaswell tacaswell mentioned this pull request Jun 15, 2023
MNT: remove test images from mathtext tests that have been removed #26132
Merged
devRD pushed a commit to devRD/matplotlib that referenced this pull request Jun 19, 2023
@tacaswell @devRD
MNT: remove test images from mathtext tests that have been removed
01bd655
b0dbead via matplotlib#19314 several tests
were merged but the images for them were not removed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@QuLogic QuLogic QuLogic approved these changes
@anntzer anntzer anntzer approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@anntzer anntzer

Labels

topic: text/mathtext

Projects

None yet

Milestone

v3.4.0

Development

Successfully merging this pull request may close these issues.

mathtext \lim is vertically misaligned

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@aitikgupta @anntzer @QuLogic
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.