Skip to content

Commit 92e63a2

Browse files
committed
Merge pull request matplotlib#2457 from mdboom/private-members
Privatize Text.cached
2 parents 3f3957c + 1f0e540 commit 92e63a2

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

Diff for: doc/api/api_changes.rst

+10
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,16 @@ For new features that were added to matplotlib, please see
1717
Changes in 1.3.x
1818
================
1919

20+
Changes in 1.3.1
21+
----------------
22+
23+
It is rare that we make an API change in a bugfix release, however,
24+
for 1.3.1 since 1.3.0 the following change was made:
25+
26+
- `text.Text.cached` (used to cache font objects) has been made into a
27+
private variable. Among the obvious encapsulation benefit, this
28+
removes this confusing-looking member from the documentation.
29+
2030
Code removal
2131
------------
2232

Diff for: lib/matplotlib/text.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ class Text(Artist):
146146
"""
147147
zorder = 3
148148

149-
cached = maxdict(50)
149+
_cached = maxdict(50)
150150

151151
def __str__(self):
152152
return "Text(%g,%g,%s)" % (self._x, self._y, repr(self._text))
@@ -285,8 +285,8 @@ def _get_layout(self, renderer):
285285
of a rotated text when necessary.
286286
"""
287287
key = self.get_prop_tup()
288-
if key in self.cached:
289-
return self.cached[key]
288+
if key in self._cached:
289+
return self._cached[key]
290290

291291
horizLayout = []
292292

@@ -440,7 +440,7 @@ def get_text_width_height_descent(*kl, **kwargs):
440440
xs, ys = xys[:, 0], xys[:, 1]
441441

442442
ret = bbox, zip(lines, whs, xs, ys), descent
443-
self.cached[key] = ret
443+
self._cached[key] = ret
444444
return ret
445445

446446
def set_bbox(self, rectprops):

0 commit comments

Comments
 (0)