Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb07fbb8

Browse files
authored
Merge pull request#8708 from QuLogic/flaky-tests
Fix flaky text tests
2 parents90ded74 +2005738 commitb07fbb8

File tree

8 files changed

+33
-8
lines changed

8 files changed

+33
-8
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Unique identifier added to `RendererBase` classes
2+
`````````````````````````````````````````````````
3+
4+
Since ``id()`` is not guaranteed to be unique between objects that exist at
5+
different times, a new private property ``_uid`` has been added to
6+
`RendererBase` which is used along with the renderer's ``id()`` to cache
7+
certain expensive operations.
8+
9+
If a custom renderer does not subclass `RendererBase` or `MixedModeRenderer`,
10+
it is not required to implement this ``_uid`` property, but this may produce
11+
incorrect behavior when the renderers' ``id()`` clashes.

‎lib/matplotlib/backend_bases.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
fromcontextlibimportcontextmanager
4242
importimportlib
4343
importio
44+
importitertools
4445
importos
4546
importsys
4647
importtime
@@ -100,6 +101,12 @@
100101
}
101102

102103

104+
# Used to ensure that caching based on renderer id() is unique without being as
105+
# expensive as a real UUID. 0 is used for renderers that don't derive from
106+
# here, so start at 1.
107+
_unique_renderer_id=itertools.count(1)
108+
109+
103110
defregister_backend(format,backend,description=None):
104111
"""
105112
Register a backend for saving to a given file format.
@@ -212,6 +219,10 @@ class RendererBase(object):
212219
213220
"""
214221
def__init__(self):
222+
# A lightweight id for unique-ification purposes. Along with id(self),
223+
# the combination should be unique enough to use as part of a cache key.
224+
self._uid=next(_unique_renderer_id)
225+
215226
self._texmanager=None
216227

217228
self._text2path=textpath.TextToPath()

‎lib/matplotlib/backends/backend_mixed.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
importsix
77

8+
importmatplotlib.backend_bases
89
frommatplotlib.backends.backend_aggimportRendererAgg
910
frommatplotlib.tight_bboximportprocess_figure_for_rasterizing
1011

@@ -49,6 +50,9 @@ def __init__(self, figure, width, height, dpi, vector_renderer,
4950
ifraster_renderer_classisNone:
5051
raster_renderer_class=RendererAgg
5152

53+
# See matplotlib.backend_bases.RendererBase._uid.
54+
self._uid=next(matplotlib.backend_bases._unique_renderer_id)
55+
5256
self._raster_renderer_class=raster_renderer_class
5357
self._width=width
5458
self._height=height

‎lib/matplotlib/tests/test_backend_pdf.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,8 @@ def test_grayscale_alpha():
178178
ax.set_yticks([])
179179

180180

181+
# This tests tends to hit a TeX cache lock on AppVeyor.
182+
@pytest.mark.flaky(reruns=3)
181183
@needs_tex
182184
deftest_missing_psfont(monkeypatch):
183185
"""An error is raised if a TeX font lacks a Type-1 equivalent"""

‎lib/matplotlib/tests/test_backend_ps.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
reason="This test needs a TeX installation")
2828

2929

30+
# This tests tends to hit a TeX cache lock on AppVeyor.
31+
@pytest.mark.flaky(reruns=3)
3032
@pytest.mark.parametrize('format, use_log, rcParams', [
3133
('ps',False, {}),
3234
needs_ghostscript(('ps',False, {'ps.usedistiller':'ghostscript'})),

‎lib/matplotlib/tests/test_mathtext.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,6 @@ def baseline_images(request, fontset, index):
167167
return ['%s_%s_%02d'% (request.param,fontset,index)]
168168

169169

170-
# See #7911 for why these tests are flaky and #7107 for why they are not so
171-
# easy to fix.
172-
@pytest.mark.flaky(reruns=3)
173170
@pytest.mark.parametrize('index, test',enumerate(math_tests),
174171
ids=[str(index)forindexinrange(len(math_tests))])
175172
@pytest.mark.parametrize('fontset',
@@ -184,9 +181,6 @@ def test_mathtext_rendering(baseline_images, fontset, index, test):
184181
horizontalalignment='center',verticalalignment='center')
185182

186183

187-
# See #7911 for why these tests are flaky and #7107 for why they are not so
188-
# easy to fix.
189-
@pytest.mark.flaky(reruns=3)
190184
@pytest.mark.parametrize('index, test',enumerate(font_tests),
191185
ids=[str(index)forindexinrange(len(font_tests))])
192186
@pytest.mark.parametrize('fontset',

‎lib/matplotlib/tests/test_tightlayout.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def test_tight_layout3():
5858

5959

6060
@image_comparison(baseline_images=['tight_layout4'],
61-
freetype_version=('2.4.5','2.4.9'))
61+
freetype_version=('2.5.5','2.6.1'))
6262
deftest_tight_layout4():
6363
'Test tight_layout for subplot2grid'
6464

‎lib/matplotlib/text.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -907,11 +907,12 @@ def get_prop_tup(self, renderer=None):
907907
need to know if the text has changed.
908908
"""
909909
x,y=self.get_unitless_position()
910+
renderer=rendererorself._renderer
910911
return (x,y,self.get_text(),self._color,
911912
self._verticalalignment,self._horizontalalignment,
912913
hash(self._fontproperties),
913914
self._rotation,self._rotation_mode,
914-
self.figure.dpi,id(rendererorself._renderer),
915+
self.figure.dpi,id(renderer),getattr(renderer,'_uid',0),
915916
self._linespacing
916917
)
917918

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp