GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — TST: Use placeholders for text in layout tests by QuLogic · Pull Request #29872 · matplotlib/matplotlib Conversation
Member
PR summaryThis is an alternative to #29833 which patches the I tested this by changing PR checklist
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
QuLogic
commented
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note, I found
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
QuLogic
force-pushed
the
layout-text-placeholders
branch
from
81dfd4b to
de67704
Compare
timhoffm
reviewed
Uh oh!
There was an error while loading. Please reload this page.
jklymak
approved these changes
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks good. I would never have known to use monkeypatch!
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
timhoffm
previously requested changes
|
| Rectangle(bbox.p0, bbox.width, bbox.height, color='grey').draw(renderer) | |
| Rectangle(bbox.p0, bbox.width, bbox.height, facecolor='grey').draw(renderer) |
color would also set the edgecolor, which is transparent by default ('none'). The edgecolor induces a line to be drawn around the region and since lines have antialiasing, the edges can become blury. We don't want that. See #29874 (comment), where the same effect shows up in a different context.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
de67704 to
35442a2
Compare
|
I pushed a couple minor tweaks:
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| return | ||
| bbox = self.get_window_extent() | ||
| rect = Rectangle(bbox.p0, bbox.width, bbox.height, | ||
| facecolor=(self.get_color(), 0.5), edgecolor='none') |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I'm a bit torn on using transparency here. On the one hand, that correctly catches overlay (but that should be rare). On the other hand, alpha blending is an additional component determining the output image, can that lead to more unstable reference images in the future?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Fair enough. I think it should only make a difference if there is overlap and the z-order changes, but that's not important enough to check here.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Test images looks a bit redacted now 😆, but I think this is better.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
35442a2 to
60c293f
Compare
|
I made one more change to 2 tests that I found in #29816 that are about tight layout, namely that calling I fixed this by setting the layout on the Figure itself, so it would be enabled on save and correctly ignore text. Also, I changed the table test to use placeholders. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
37e5518 to
064c10e
Compare
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This should also be mentioned in
https://matplotlib.org/devdocs/devel/testing.html#writing-an-image-comparison-test
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
d46840e to
7c466f9
Compare
There was an error while loading. Please reload this page.
|
While updating that doc section, I was also reminded that we should prefer |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I would do the mpl20 change in one go. I checked the diffs: The smaller figure sizes are ok. AFAICS no layout information is lost. The only one I'm not sure about is tight_layout_offsetboxes2.svg The offset boxes (red/green) and the labels of the right column overlap. But I guess that's just how tightlayout works. It does not account for the actual label sizes. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Tight_layout should account for the actual reported label sizes. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
So is this an issue due the rectangle not representing the actual text width but rather an approximation? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I'm not sure - I dont' see an equivalent test for constrained layout - but maybe it is a draw twice sort of error, where the offset boxes get moved when the axes gets resized, and therefore the margin made for the axes is too small for th new position. We run constrained layout twice to get around that; usually the position is "closer" after the first time and the new margin is big enough. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Hm @QuLogic maybe the workaround here could be to increase the figure size to not be bothered with this topic right now? 🤯 Not great, but digging into whether this is a tightlayout issue or a box approximation issue also does not feel like a good use of time. And I don't like the present image with the overlap. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
But these are not labels, they are Based on the comment in the test, it appears the intention is to ensure that the boxes are included in the Axes bounding box, but not necessarily have any effect on the ticks labels. Then the real test is the difference between 1 and 2, where the invisible So I think that a) we can drop this test down to just .png since it's really just checking if a specific artist is included, b) maybe we should remove the tick labels entirely to avoid confusing ourselves, and c) maybe this doesn't need to be an image test at all? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Oh I see. Yes the boxes can overlap the labels in their own axes. They should not overlap labels in other axes. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Here's my suggestion for removing the image from the test: b6dff32 It creates 3 figures:
Then the test is that in figure 2, each If that makes some sense, then I'll rebase this PR on top of that, so we can drop the figures before changing them here. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
If we pass `remove_text` to `image_comparison`, we don't expect tests to change from FreeType. But if `tight_layout` is called *before* the end of the test function, the layout will happen with the text that was supposed to be removed.
Co-authored-by: Tim Hoffmann <[email protected]>
|
I am 👍 on moving to the version of that test that @QuLogic has proposed and moving all of these to mpl20 style in this PR. I think that this is the next PR in the sequence to move to freetype 2.13 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
7c466f9 to
3d0fd3c
Compare
…872-on-v3.10.x Backport PR #29872 on branch v3.10.x (TST: Use placeholders for text in layout tests)
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.