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

Appearance settings

Commit 8ce1e02

Browse filesBrowse files
authored
Merge pull request #20078 from timhoffm/ordered-dict
Remove some usages of OrderedDict
2 parents c65140f + aafaa9d commit 8ce1e02
Copy full SHA for 8ce1e02

File tree

Expand file treeCollapse file tree

8 files changed

+25
-40
lines changed
Filter options
Expand file treeCollapse file tree

8 files changed

+25
-40
lines changed

‎examples/lines_bars_and_markers/filled_step.py

Copy file name to clipboardExpand all lines: examples/lines_bars_and_markers/filled_step.py
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
"""
88

99
import itertools
10-
from collections import OrderedDict
1110
from functools import partial
1211

1312
import numpy as np
@@ -188,7 +187,7 @@ def stack_hist(ax, stacked_data, sty_cycle, bottoms=None,
188187
np.random.seed(19680801)
189188

190189
stack_data = np.random.randn(4, 12250)
191-
dict_data = OrderedDict(zip((c['label'] for c in label_cycle), stack_data))
190+
dict_data = dict(zip((c['label'] for c in label_cycle), stack_data))
192191

193192
###############################################################################
194193
# Work with plain arrays

‎lib/matplotlib/_color_data.py

Copy file name to clipboardExpand all lines: lib/matplotlib/_color_data.py
+12-18Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
from collections import OrderedDict
2-
3-
41
BASE_COLORS = {
52
'b': (0, 0, 1), # blue
63
'g': (0, 0.5, 0), # green
@@ -14,22 +11,19 @@
1411

1512

1613
# These colors are from Tableau
17-
TABLEAU_COLORS = (
18-
('blue', '#1f77b4'),
19-
('orange', '#ff7f0e'),
20-
('green', '#2ca02c'),
21-
('red', '#d62728'),
22-
('purple', '#9467bd'),
23-
('brown', '#8c564b'),
24-
('pink', '#e377c2'),
25-
('gray', '#7f7f7f'),
26-
('olive', '#bcbd22'),
27-
('cyan', '#17becf'),
28-
)
14+
TABLEAU_COLORS = {
15+
'tab:blue': '#1f77b4',
16+
'tab:orange': '#ff7f0e',
17+
'tab:green': '#2ca02c',
18+
'tab:red': '#d62728',
19+
'tab:purple': '#9467bd',
20+
'tab:brown': '#8c564b',
21+
'tab:pink': '#e377c2',
22+
'tab:gray': '#7f7f7f',
23+
'tab:olive': '#bcbd22',
24+
'tab:cyan': '#17becf',
25+
}
2926

30-
# Normalize name to "tab:<name>" to avoid name collisions.
31-
TABLEAU_COLORS = OrderedDict(
32-
('tab:' + name, value) for name, value in TABLEAU_COLORS)
3327

3428
# This mapping of color names -> hex values is taken from
3529
# a survey run by Randall Munroe see:

‎lib/matplotlib/artist.py

Copy file name to clipboardExpand all lines: lib/matplotlib/artist.py
+2-3Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from collections import OrderedDict, namedtuple
1+
from collections import namedtuple
22
from functools import wraps
33
import inspect
44
import logging
@@ -1659,8 +1659,7 @@ def setp(obj, *args, file=None, **kwargs):
16591659
if len(args) % 2:
16601660
raise ValueError('The set args must be string, value pairs')
16611661

1662-
# put args into ordereddict to maintain order
1663-
funcvals = OrderedDict((k, v) for k, v in zip(args[::2], args[1::2]))
1662+
funcvals = dict(zip(args[::2], args[1::2]))
16641663
ret = [o.update(funcvals) for o in objs] + [o.set(**kwargs) for o in objs]
16651664
return list(cbook.flatten(ret))
16661665

‎lib/matplotlib/backends/backend_pdf.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/backend_pdf.py
+3-5Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
"""
66

77
import codecs
8-
import collections
98
from datetime import datetime
109
from enum import Enum
1110
from functools import total_ordering
@@ -682,15 +681,14 @@ def __init__(self, filename, metadata=None):
682681
self._soft_mask_states = {}
683682
self._soft_mask_seq = (Name(f'SM{i}') for i in itertools.count(1))
684683
self._soft_mask_groups = []
685-
# reproducible writeHatches needs an ordered dict:
686-
self.hatchPatterns = collections.OrderedDict()
684+
self.hatchPatterns = {}
687685
self._hatch_pattern_seq = (Name(f'H{i}') for i in itertools.count(1))
688686
self.gouraudTriangles = []
689687

690-
self._images = collections.OrderedDict() # reproducible writeImages
688+
self._images = {}
691689
self._image_seq = (Name(f'I{i}') for i in itertools.count(1))
692690

693-
self.markers = collections.OrderedDict() # reproducible writeMarkers
691+
self.markers = {}
694692
self.multi_byte_charprocs = {}
695693

696694
self.paths = []

‎lib/matplotlib/backends/backend_svg.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/backend_svg.py
+3-4Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from collections import OrderedDict
21
import base64
32
import datetime
43
import gzip
@@ -287,10 +286,10 @@ def __init__(self, width, height, svgwriter, basename=None, image_dpi=72,
287286
self._groupd = {}
288287
self.basename = basename
289288
self._image_counter = itertools.count()
290-
self._clipd = OrderedDict()
289+
self._clipd = {}
291290
self._markers = {}
292291
self._path_collection_id = 0
293-
self._hatchd = OrderedDict()
292+
self._hatchd = {}
294293
self._has_gouraud = False
295294
self._n_gradients = 0
296295

@@ -1174,7 +1173,7 @@ def _draw_text_as_text(self, gc, x, y, s, prop, angle, ismath, mtext=None):
11741173
writer.start('text')
11751174

11761175
# Sort the characters by font, and output one tspan for each.
1177-
spans = OrderedDict()
1176+
spans = {}
11781177
for font, fontsize, thetext, new_x, new_y in glyphs:
11791178
style = generate_css({
11801179
'font-size': short_float_fmt(fontsize) + 'px',

‎lib/matplotlib/tests/test_rcparams.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_rcparams.py
+1-3Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from collections import OrderedDict
21
import copy
32
import os
43
from pathlib import Path
@@ -460,8 +459,7 @@ def test_rcparams_reset_after_fail():
460459
with mpl.rc_context(rc={'text.usetex': False}):
461460
assert mpl.rcParams['text.usetex'] is False
462461
with pytest.raises(KeyError):
463-
with mpl.rc_context(rc=OrderedDict([('text.usetex', True),
464-
('test.blah', True)])):
462+
with mpl.rc_context(rc={'text.usetex': True, 'test.blah': True}):
465463
pass
466464
assert mpl.rcParams['text.usetex'] is False
467465

‎lib/matplotlib/tests/test_style.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_style.py
+1-3Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from collections import OrderedDict
21
from contextlib import contextmanager
32
import gc
43
from pathlib import Path
@@ -138,10 +137,9 @@ def test_context_with_union_of_dict_and_namedstyle():
138137
def test_context_with_badparam():
139138
original_value = 'gray'
140139
other_value = 'blue'
141-
d = OrderedDict([(PARAM, original_value), ('badparam', None)])
142140
with style.context({PARAM: other_value}):
143141
assert mpl.rcParams[PARAM] == other_value
144-
x = style.context([d])
142+
x = style.context({PARAM: original_value, 'badparam': None})
145143
with pytest.raises(KeyError):
146144
with x:
147145
pass

‎tutorials/colors/colormaps.py

Copy file name to clipboardExpand all lines: tutorials/colors/colormaps.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@
7878
import matplotlib.pyplot as plt
7979
from matplotlib import cm
8080
from colorspacious import cspace_converter
81-
from collections import OrderedDict
8281

83-
cmaps = OrderedDict()
82+
83+
cmaps = {}
8484

8585
###############################################################################
8686
# Sequential

0 commit comments

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