Skip to content

Navigation Menu

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

Appearance settings

Commit 55c7f43

Browse filesBrowse files
author
ojeda-e
committed
moved cache to Text attribute.
1 parent 80a839e commit 55c7f43
Copy full SHA for 55c7f43

File tree

2 files changed

+16
-2
lines changed
Filter options

2 files changed

+16
-2
lines changed

‎lib/matplotlib/tests/test_text.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_text.py
+15-1Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import numpy as np
66
from numpy.testing import assert_almost_equal
77
import pytest
8-
8+
import time
99
import matplotlib as mpl
1010
from matplotlib.backend_bases import MouseEvent
1111
from matplotlib.font_manager import FontProperties
@@ -756,3 +756,17 @@ def test_pdf_chars_beyond_bmp():
756756
plt.rcParams['mathtext.fontset'] = 'stixsans'
757757
plt.figure()
758758
plt.figtext(0.1, 0.5, "Mass $m$ \U00010308", size=30)
759+
760+
761+
def test_cache_large_labels():
762+
"""Test to verify cache helps when ticks are too large"""
763+
times = []
764+
for pow in range(1, 5):
765+
labels = [i for i in range(10**pow)]
766+
t0 = time.perf_counter()
767+
plt.figure()
768+
plt.xticks(labels)
769+
plt.yticks(labels)
770+
times.append(time.perf_counter()-t0)
771+
assert times[-1] > times[0]
772+
assert times[-1] > times[-2]

‎lib/matplotlib/text.py

Copy file name to clipboardExpand all lines: lib/matplotlib/text.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ class Text(Artist):
107107
"""Handle storing and drawing of text in window or data coordinates."""
108108

109109
zorder = 3
110-
_cached = cbook.maxdict(50)
111110

112111
def __repr__(self):
113112
return "Text(%s, %s, %s)" % (self._x, self._y, repr(self._text))
@@ -158,6 +157,7 @@ def __init__(self,
158157
self._linespacing = linespacing
159158
self.set_rotation_mode(rotation_mode)
160159
self.update(kwargs)
160+
self._cached = cbook.maxdict(50)
161161

162162
def update(self, kwargs):
163163
# docstring inherited

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.