Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e77bd0b

Browse files
committed
Fix ordering of tex font usepackages.
Sets do not maintain insertion order even with recent pythons (try e.g. `for _ in $(seq 10); do python -c 'print({"a", "b"})'; done`), but we have `cbook._OrderedSet` for that. Keeping usepackage order can matter for caching purposes.
1 parent 36c6632 commit e77bd0b

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

lib/matplotlib/cbook/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2014,8 +2014,9 @@ def _setattr_cm(obj, **kwargs):
20142014

20152015

20162016
class _OrderedSet(collections.abc.MutableSet):
2017-
def __init__(self):
2017+
def __init__(self, iterable=()):
20182018
self._od = collections.OrderedDict()
2019+
self |= iterable
20192020

20202021
def __contains__(self, key):
20212022
return key in self._od

lib/matplotlib/texmanager.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,9 @@ def get_font_config(self):
110110

111111
# The following packages and commands need to be included in the latex
112112
# file's preamble:
113-
cmd = {fonts[family][1]
114-
for family in ['serif', 'sans-serif', 'monospace']}
113+
cmd = cbook._OrderedSet(
114+
fonts[family][1]
115+
for family in ['serif', 'sans-serif', 'monospace'])
115116
if self.font_family == 'cursive':
116117
cmd.add(fonts['cursive'][1])
117118
cmd.add(r'\usepackage{type1cm}')

0 commit comments

Comments
 (0)