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

Fix flaky text tests#8708

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
anntzer merged 4 commits intomatplotlib:masterfromQuLogic:flaky-tests
Jun 10, 2017
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletionsdoc/api/api_changes/2017-06-03-ES_unique_renderer.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
Unique identifier added to `RendererBase` classes
`````````````````````````````````````````````````

Since ``id()`` is not guaranteed to be unique between objects that exist at
different times, a new private property ``_uid`` has been added to
`RendererBase` which is used along with the renderer's ``id()`` to cache
certain expensive operations.

If a custom renderer does not subclass `RendererBase` or `MixedModeRenderer`,
it is not required to implement this ``_uid`` property, but this may produce
incorrect behavior when the renderers' ``id()`` clashes.
11 changes: 11 additions & 0 deletionslib/matplotlib/backend_bases.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -41,6 +41,7 @@
from contextlib import contextmanager
import importlib
import io
import itertools
import os
import sys
import time
Expand DownExpand Up@@ -100,6 +101,12 @@
}


# Used to ensure that caching based on renderer id() is unique without being as
# expensive as a real UUID. 0 is used for renderers that don't derive from
# here, so start at 1.
_unique_renderer_id = itertools.count(1)


def register_backend(format, backend, description=None):
"""
Register a backend for saving to a given file format.
Expand DownExpand Up@@ -212,6 +219,10 @@ class RendererBase(object):

"""
def __init__(self):
# A lightweight id for unique-ification purposes. Along with id(self),
# the combination should be unique enough to use as part of a cache key.
self._uid = next(_unique_renderer_id)

self._texmanager = None

self._text2path = textpath.TextToPath()
Expand Down
4 changes: 4 additions & 0 deletionslib/matplotlib/backends/backend_mixed.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,6 +5,7 @@

import six

import matplotlib.backend_bases
from matplotlib.backends.backend_agg import RendererAgg
from matplotlib.tight_bbox import process_figure_for_rasterizing

Expand DownExpand Up@@ -49,6 +50,9 @@ def __init__(self, figure, width, height, dpi, vector_renderer,
if raster_renderer_class is None:
raster_renderer_class = RendererAgg

# See matplotlib.backend_bases.RendererBase._uid.
self._uid = next(matplotlib.backend_bases._unique_renderer_id)

self._raster_renderer_class = raster_renderer_class
self._width = width
self._height = height
Expand Down
2 changes: 2 additions & 0 deletionslib/matplotlib/tests/test_backend_pdf.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -178,6 +178,8 @@ def test_grayscale_alpha():
ax.set_yticks([])


# This tests tends to hit a TeX cache lock on AppVeyor.
@pytest.mark.flaky(reruns=3)
@needs_tex
def test_missing_psfont(monkeypatch):
"""An error is raised if a TeX font lacks a Type-1 equivalent"""
Expand Down
2 changes: 2 additions & 0 deletionslib/matplotlib/tests/test_backend_ps.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -27,6 +27,8 @@
reason="This test needs a TeX installation")


# This tests tends to hit a TeX cache lock on AppVeyor.
@pytest.mark.flaky(reruns=3)
@pytest.mark.parametrize('format, use_log, rcParams', [
('ps', False, {}),
needs_ghostscript(('ps', False, {'ps.usedistiller': 'ghostscript'})),
Expand Down
6 changes: 0 additions & 6 deletionslib/matplotlib/tests/test_mathtext.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -167,9 +167,6 @@ def baseline_images(request, fontset, index):
return ['%s_%s_%02d' % (request.param, fontset, index)]


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


# See #7911 for why these tests are flaky and #7107 for why they are not so
# easy to fix.
@pytest.mark.flaky(reruns=3)
@pytest.mark.parametrize('index, test', enumerate(font_tests),
ids=[str(index) for index in range(len(font_tests))])
@pytest.mark.parametrize('fontset',
Expand Down
2 changes: 1 addition & 1 deletionlib/matplotlib/tests/test_tightlayout.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -58,7 +58,7 @@ def test_tight_layout3():


@image_comparison(baseline_images=['tight_layout4'],
freetype_version=('2.4.5', '2.4.9'))
freetype_version=('2.5.5', '2.6.1'))
def test_tight_layout4():
'Test tight_layout for subplot2grid'

Expand Down
3 changes: 2 additions & 1 deletionlib/matplotlib/text.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -907,11 +907,12 @@ def get_prop_tup(self, renderer=None):
need to know if the text has changed.
"""
x, y = self.get_unitless_position()
renderer = renderer or self._renderer
return (x, y, self.get_text(), self._color,
self._verticalalignment, self._horizontalalignment,
hash(self._fontproperties),
self._rotation, self._rotation_mode,
self.figure.dpi, id(renderer or self._renderer),
self.figure.dpi, id(renderer), getattr(renderer, '_uid', 0),
self._linespacing
)

Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp