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

Commit55c7f43

Browse files
author
ojeda-e
committed
moved cache to Text attribute.
1 parent80a839e commit55c7f43

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

‎lib/matplotlib/tests/test_text.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
importnumpyasnp
66
fromnumpy.testingimportassert_almost_equal
77
importpytest
8-
8+
importtime
99
importmatplotlibasmpl
1010
frommatplotlib.backend_basesimportMouseEvent
1111
frommatplotlib.font_managerimportFontProperties
@@ -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+
deftest_cache_large_labels():
762+
"""Test to verify cache helps when ticks are too large"""
763+
times= []
764+
forpowinrange(1,5):
765+
labels= [iforiinrange(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+
asserttimes[-1]>times[0]
772+
asserttimes[-1]>times[-2]

‎lib/matplotlib/text.py

Lines 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
defupdate(self,kwargs):
163163
# docstring inherited

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp