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 from1 commit
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
PrevPrevious commit
Use itertools.count for renderer unique ID.
As suggested by@anntzer.
  • Loading branch information
@QuLogic
QuLogic committedJun 4, 2017
commit2005738a8dca9e1663fafc7114ffc0f4b982b012
25 changes: 8 additions & 17 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@@ -101,8 +102,9 @@


# Used to ensure that caching based on renderer id() is unique without being as
# expensive as a real UUID.
_unique_renderer_id = 0
# 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):
Expand DownExpand Up@@ -217,25 +219,14 @@ class RendererBase(object):

"""
def __init__(self):
self._id = None
# 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()

@property
def _uid(self):
"""
A lightweight id for unique-ification purposes.

Along with id(self), this combination should be unique enough to use as
part of a caching key.
"""
if self._id is None:
global _unique_renderer_id
_unique_renderer_id += 1
self._id = _unique_renderer_id
return self._id

def open_group(self, s, gid=None):
"""
Open a grouping element with label *s*. If *gid* is given, use
Expand Down
17 changes: 4 additions & 13 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,7 +50,9 @@ def __init__(self, figure, width, height, dpi, vector_renderer,
if raster_renderer_class is None:
raster_renderer_class = RendererAgg

self._id = None
# 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 DownExpand Up@@ -81,18 +84,6 @@ def __init__(self, figure, width, height, dpi, vector_renderer,
_text2path _get_text_path_transform height width
""".split()

@property
def _uid(self):
"""
See matplotlib.backend_bases.RendererBase._uid.
"""
if self._id is None:
from matplotlib import backend_bases
backend_bases._unique_renderer_id
backend_bases._unique_renderer_id += 1
self._id = backend_bases._unique_renderer_id
return self._id

def _set_current_renderer(self, renderer):
self._renderer = renderer

Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp