FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Fix over/under mathtext symbols by aitikgupta · Pull Request #19314 · matplotlib/matplotlib · GitHub

Repository navigation

Fix over/under mathtext symbols - #19314

Merged
QuLogic merged 5 commits into
matplotlib:masterfrom
aitikgupta:overunder-alignment
Feb 10, 2021
Merged

QuLogic merged 5 commits into
matplotlib:masterfrom
aitikgupta:overunder-alignment

Conversation

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).

aitikgupta commented Jan 18, 2021 •
edited
Loading

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:

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...)

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.

aitikgupta commented Jan 19, 2021 •
edited
Loading

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 :)

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.

aitikgupta commented Jan 20, 2021 •
edited
Loading

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?

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 commented Jan 20, 2021 •
edited
Loading

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"
  ]

aitikgupta commented Feb 4, 2021 •
edited
Loading

Copy link
Copy Markdown
Contributor Author

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

QuLogic commented Feb 4, 2021

Copy link
Copy Markdown
Member

It would need a second review.

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

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.)

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.


(side by side)

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

anntzer commented Feb 7, 2021 •
edited
Loading

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"].)

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?

anntzer commented Feb 9, 2021 •
edited
Loading

Copy link
Copy Markdown
Contributor

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

QuLogic commented Feb 10, 2021

Copy link
Copy Markdown
Member

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

QuLogic merged commit 8ff6e8a into matplotlib:master Feb 10, 2021
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
b0dbead via matplotlib#19314 several tests
were merged but the images for them were not removed.
devRD pushed a commit to devRD/matplotlib that referenced this pull request Jun 19, 2023
b0dbead via matplotlib#19314 several tests
were merged but the images for them were not removed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mathtext \lim is vertically misaligned

3 participants


Back | FazBrowse Home | New Git URL