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 7a83fc4

Browse filesBrowse files
committed
Iterating over a dict is easy.
1 parent 70909c4 commit 7a83fc4
Copy full SHA for 7a83fc4
Expand file treeCollapse file tree

21 files changed

+48
-76
lines changed

‎lib/matplotlib/__init__.py

Copy file name to clipboardExpand all lines: lib/matplotlib/__init__.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1894,4 +1894,4 @@ def inner(ax, *args, **kwargs):
18941894
verbose.report('verbose.level %s' % verbose.level)
18951895
verbose.report('interactive is %s' % is_interactive())
18961896
verbose.report('platform is %s' % sys.platform)
1897-
verbose.report('loaded modules: %s' % six.iterkeys(sys.modules), 'debug')
1897+
verbose.report('loaded modules: %s' % list(sys.modules), 'debug')

‎lib/matplotlib/artist.py

Copy file name to clipboardExpand all lines: lib/matplotlib/artist.py
+1-5Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1317,12 +1317,8 @@ def pprint_getters(self):
13171317
Return the getters and actual values as list of strings.
13181318
"""
13191319

1320-
d = self.properties()
1321-
names = list(six.iterkeys(d))
1322-
names.sort()
13231320
lines = []
1324-
for name in names:
1325-
val = d[name]
1321+
for name, val in sorted(six.iteritems(self.properties())):
13261322
if getattr(val, 'shape', ()) != () and len(val) > 6:
13271323
s = str(val[:6]) + '...'
13281324
else:

‎lib/matplotlib/axes/_base.py

Copy file name to clipboardExpand all lines: lib/matplotlib/axes/_base.py
+4-7Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1332,12 +1332,11 @@ def set_anchor(self, anchor):
13321332
===== ============
13331333
13341334
"""
1335-
if (anchor in list(six.iterkeys(mtransforms.Bbox.coefs)) or
1336-
len(anchor) == 2):
1335+
if anchor in mtransforms.Bbox.coefs or len(anchor) == 2:
13371336
self._anchor = anchor
13381337
else:
13391338
raise ValueError('argument must be among %s' %
1340-
', '.join(six.iterkeys(mtransforms.Bbox.coefs)))
1339+
', '.join(mtransforms.Bbox.coefs))
13411340
self.stale = True
13421341

13431342
def get_data_ratio(self):
@@ -2877,8 +2876,7 @@ def set_xlim(self, left=None, right=None, emit=True, auto=False, **kw):
28772876
if 'xmax' in kw:
28782877
right = kw.pop('xmax')
28792878
if kw:
2880-
raise ValueError("unrecognized kwargs: %s" %
2881-
list(six.iterkeys(kw)))
2879+
raise ValueError("unrecognized kwargs: %s" % list(kw))
28822880

28832881
if right is None and iterable(left):
28842882
left, right = left
@@ -3158,8 +3156,7 @@ def set_ylim(self, bottom=None, top=None, emit=True, auto=False, **kw):
31583156
if 'ymax' in kw:
31593157
top = kw.pop('ymax')
31603158
if kw:
3161-
raise ValueError("unrecognized kwargs: %s" %
3162-
list(six.iterkeys(kw)))
3159+
raise ValueError("unrecognized kwargs: %s" % list(kw))
31633160

31643161
if top is None and iterable(bottom):
31653162
bottom, top = bottom

‎lib/matplotlib/backends/backend_pdf.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/backend_pdf.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1533,7 +1533,7 @@ def is_date(x):
15331533
'CreationDate': is_date,
15341534
'ModDate': is_date,
15351535
'Trapped': check_trapped}
1536-
for k in six.iterkeys(self.infoDict):
1536+
for k in self.infoDict:
15371537
if k not in keywords:
15381538
warnings.warn('Unknown infodict keyword: %s' % k)
15391539
else:

‎lib/matplotlib/backends/backend_ps.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/backend_ps.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -958,8 +958,8 @@ def _print_ps(self, outfile, format, *args, **kwargs):
958958
if papertype == 'auto':
959959
pass
960960
elif papertype not in papersize:
961-
raise RuntimeError( '%s is not a valid papertype. Use one \
962-
of %s'% (papertype, ', '.join(six.iterkeys(papersize))))
961+
raise RuntimeError('%s is not a valid papertype. Use one of %s' %
962+
(papertype, ', '.join(papersize)))
963963

964964
orientation = kwargs.pop("orientation", "portrait").lower()
965965
if orientation == 'landscape': isLandscape = True

‎lib/matplotlib/backends/backend_svg.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/backend_svg.py
+2-4Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -593,10 +593,8 @@ def draw_markers(self, gc, marker_path, marker_trans, path, trans, rgbFace=None)
593593
style = self._get_style_dict(gc, rgbFace)
594594
dictkey = (path_data, generate_css(style))
595595
oid = self._markers.get(dictkey)
596-
for key in list(six.iterkeys(style)):
597-
if not key.startswith('stroke'):
598-
del style[key]
599-
style = generate_css(style)
596+
style = generate_css({k: v for k, v in six.iteritems(style)
597+
if k.startswith('stroke')})
600598

601599
if oid is None:
602600
oid = self._make_id('m', dictkey)

‎lib/matplotlib/cbook.py

Copy file name to clipboardExpand all lines: lib/matplotlib/cbook.py
+3-5Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -668,10 +668,8 @@ def __init__(self, **kwds):
668668
self.__dict__.update(kwds)
669669

670670
def __repr__(self):
671-
keys = six.iterkeys(self.__dict__)
672-
return 'Bunch(%s)' % ', '.join(['%s=%s' % (k, self.__dict__[k])
673-
for k
674-
in keys])
671+
return 'Bunch(%s)' % ', '.join(
672+
'%s=%s' % kv for kv in six.iteritems(vars(self)))
675673

676674

677675
@deprecated('2.1')
@@ -940,7 +938,7 @@ class Xlator(dict):
940938

941939
def _make_regex(self):
942940
""" Build re object based on the keys of the current dictionary """
943-
return re.compile("|".join(map(re.escape, list(six.iterkeys(self)))))
941+
return re.compile("|".join(map(re.escape, self)))
944942

945943
def __call__(self, match):
946944
""" Handler invoked for each regex *match* """

‎lib/matplotlib/cm.py

Copy file name to clipboardExpand all lines: lib/matplotlib/cm.py
+4-7Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,16 +86,13 @@ def _generate_cmap(name, lutsize):
8686
with _warnings.catch_warnings():
8787
_warnings.simplefilter("ignore")
8888
# Generate the reversed specifications ...
89-
for cmapname in list(six.iterkeys(datad)):
90-
spec = datad[cmapname]
91-
spec_reversed = _reverse_cmap_spec(spec)
92-
datad[cmapname + '_r'] = spec_reversed
89+
for cmapname, spec in list(six.iteritems(datad)):
90+
datad[cmapname + '_r'] = _reverse_cmap_spec(spec)
9391

9492
# Precache the cmaps with ``lutsize = LUTSIZE`` ...
9593

96-
# Use datad.keys() to also add the reversed ones added in the section
97-
# above:
98-
for cmapname in six.iterkeys(datad):
94+
# Also add the reversed ones added in the section above:
95+
for cmapname in datad:
9996
cmap_d[cmapname] = _generate_cmap(cmapname, LUTSIZE)
10097

10198
cmap_d.update(cmaps_listed)

‎lib/matplotlib/dviread.py

Copy file name to clipboardExpand all lines: lib/matplotlib/dviread.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ def __init__(self, scale, tfm, texname, vf):
532532
scale, tfm, texname, vf
533533
self.size = scale * (72.0 / (72.27 * 2**16))
534534
try:
535-
nchars = max(six.iterkeys(tfm.width)) + 1
535+
nchars = max(tfm.width) + 1
536536
except ValueError:
537537
nchars = 0
538538
self.widths = [(1000*tfm.width.get(char, 0)) >> 20

‎lib/matplotlib/font_manager.py

Copy file name to clipboardExpand all lines: lib/matplotlib/font_manager.py
+2-6Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ def win32InstalledFonts(directory=None, fontext='ttf'):
247247
continue
248248
except MemoryError:
249249
continue
250-
return list(six.iterkeys(items))
250+
return list(items)
251251
finally:
252252
winreg.CloseKey(local)
253253
return None
@@ -439,11 +439,7 @@ def ttfFontProperty(font):
439439
# 600 (semibold, demibold), 700 (bold), 800 (heavy), 900 (black)
440440
# lighter and bolder are also allowed.
441441

442-
weight = None
443-
for w in six.iterkeys(weight_dict):
444-
if sfnt4.find(w) >= 0:
445-
weight = w
446-
break
442+
weight = next((w for w in weight_dict if sfnt4.find(w) >= 0), None)
447443
if not weight:
448444
if font.style_flags & ft2font.BOLD:
449445
weight = 700

‎lib/matplotlib/image.py

Copy file name to clipboardExpand all lines: lib/matplotlib/image.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
'blackman': _image.BLACKMAN,
5757
}
5858

59-
interpolations_names = set(six.iterkeys(_interpd_))
59+
interpolations_names = set(_interpd_)
6060

6161

6262
def composite_images(images, renderer, magnification=1.0):
@@ -1224,7 +1224,7 @@ def pilread(fname):
12241224
if im is None:
12251225
raise ValueError('Only know how to handle extensions: %s; '
12261226
'with Pillow installed matplotlib can handle '
1227-
'more images' % list(six.iterkeys(handlers)))
1227+
'more images' % list(handlers))
12281228
return im
12291229

12301230
handler = handlers[ext]

‎lib/matplotlib/legend.py

Copy file name to clipboardExpand all lines: lib/matplotlib/legend.py
+2-4Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -323,15 +323,13 @@ def __init__(self, parent, handles, labels,
323323
if self.isaxes:
324324
warnings.warn('Unrecognized location "%s". Falling back '
325325
'on "best"; valid locations are\n\t%s\n'
326-
% (loc, '\n\t'.join(
327-
six.iterkeys(self.codes))))
326+
% (loc, '\n\t'.join(self.codes)))
328327
loc = 0
329328
else:
330329
warnings.warn('Unrecognized location "%s". Falling back '
331330
'on "upper right"; '
332331
'valid locations are\n\t%s\n'
333-
% (loc, '\n\t'.join(
334-
six.iterkeys(self.codes))))
332+
% (loc, '\n\t'.join(self.codes)))
335333
loc = 1
336334
else:
337335
loc = self.codes[loc]

‎lib/matplotlib/lines.py

Copy file name to clipboardExpand all lines: lib/matplotlib/lines.py
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,8 +264,7 @@ class Line2D(Artist):
264264
drawStyles.update(_drawStyles_l)
265265
drawStyles.update(_drawStyles_s)
266266
# Need a list ordered with long names first:
267-
drawStyleKeys = (list(six.iterkeys(_drawStyles_l)) +
268-
list(six.iterkeys(_drawStyles_s)))
267+
drawStyleKeys = list(_drawStyles_l) + list(_drawStyles_s)
269268

270269
# Referenced here to maintain API. These are defined in
271270
# MarkerStyle

‎lib/matplotlib/mathtext.py

Copy file name to clipboardExpand all lines: lib/matplotlib/mathtext.py
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2358,7 +2358,7 @@ def __init__(self):
23582358
p.rbracket <<= Literal(']').suppress()
23592359
p.bslash <<= Literal('\\')
23602360

2361-
p.space <<= oneOf(list(six.iterkeys(self._space_widths)))
2361+
p.space <<= oneOf(list(self._space_widths))
23622362
p.customspace <<= (Suppress(Literal(r'\hspace'))
23632363
- ((p.lbrace + p.float_literal + p.rbrace)
23642364
| Error(r"Expected \hspace{n}")))
@@ -2367,17 +2367,17 @@ def __init__(self):
23672367
p.single_symbol <<= Regex(r"([a-zA-Z0-9 +\-*/<>=:,.;!\?&'@()\[\]|%s])|(\\[%%${}\[\]_|])" %
23682368
unicode_range)
23692369
p.snowflake <<= Suppress(p.bslash) + oneOf(self._snowflake)
2370-
p.symbol_name <<= (Combine(p.bslash + oneOf(list(six.iterkeys(tex2uni)))) +
2370+
p.symbol_name <<= (Combine(p.bslash + oneOf(list(tex2uni))) +
23712371
FollowedBy(Regex("[^A-Za-z]").leaveWhitespace() | StringEnd()))
23722372
p.symbol <<= (p.single_symbol | p.symbol_name).leaveWhitespace()
23732373

23742374
p.apostrophe <<= Regex("'+")
23752375

2376-
p.c_over_c <<= Suppress(p.bslash) + oneOf(list(six.iterkeys(self._char_over_chars)))
2376+
p.c_over_c <<= Suppress(p.bslash) + oneOf(list(self._char_over_chars))
23772377

23782378
p.accent <<= Group(
23792379
Suppress(p.bslash)
2380-
+ oneOf(list(six.iterkeys(self._accent_map)) + list(self._wide_accents))
2380+
+ oneOf(list(self._accent_map) + list(self._wide_accents))
23812381
- p.placeable
23822382
)
23832383

‎lib/matplotlib/mlab.py

Copy file name to clipboardExpand all lines: lib/matplotlib/mlab.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2572,7 +2572,7 @@ def mapped_r2field(name):
25722572

25732573
if jointype != 'inner' and defaults is not None:
25742574
# fill in the defaults enmasse
2575-
newrec_fields = list(six.iterkeys(newrec.dtype.fields))
2575+
newrec_fields = list(newrec.dtype.fields)
25762576
for k, v in six.iteritems(defaults):
25772577
if k in newrec_fields:
25782578
newrec[k] = v

‎lib/matplotlib/offsetbox.py

Copy file name to clipboardExpand all lines: lib/matplotlib/offsetbox.py
+7-11Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1236,20 +1236,16 @@ def __init__(self, s, loc, pad=0.4, borderpad=0.5, prop=None, **kwargs):
12361236

12371237
if prop is None:
12381238
prop = {}
1239-
propkeys = list(six.iterkeys(prop))
1240-
badkwargs = ('ha', 'horizontalalignment', 'va', 'verticalalignment')
1241-
if set(badkwargs) & set(propkeys):
1239+
badkwargs = {'ha', 'horizontalalignment', 'va', 'verticalalignment'}
1240+
if badkwargs & set(prop):
12421241
warnings.warn("Mixing horizontalalignment or verticalalignment "
1243-
"with AnchoredText is not supported.")
1242+
"with AnchoredText is not supported.")
12441243

1245-
self.txt = TextArea(s, textprops=prop,
1246-
minimumdescent=False)
1244+
self.txt = TextArea(s, textprops=prop, minimumdescent=False)
12471245
fp = self.txt._text.get_fontproperties()
1248-
1249-
super(AnchoredText, self).__init__(loc, pad=pad, borderpad=borderpad,
1250-
child=self.txt,
1251-
prop=fp,
1252-
**kwargs)
1246+
super(AnchoredText, self).__init__(
1247+
loc, pad=pad, borderpad=borderpad, child=self.txt, prop=fp,
1248+
**kwargs)
12531249

12541250

12551251
class OffsetImage(OffsetBox):

‎lib/matplotlib/path.py

Copy file name to clipboardExpand all lines: lib/matplotlib/path.py
+1-3Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,9 +203,7 @@ def _fast_from_codes_and_verts(cls, verts, codes, internals=None):
203203
if internals:
204204
raise ValueError('Unexpected internals provided to '
205205
'_fast_from_codes_and_verts: '
206-
'{0}'.format('\n *'.join(six.iterkeys(
207-
internals
208-
))))
206+
'{0}'.format('\n *'.join(internals)))
209207
return pth
210208

211209
def _update_values(self):

‎lib/matplotlib/table.py

Copy file name to clipboardExpand all lines: lib/matplotlib/table.py
+5-6Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ def __init__(self, ax, loc=None, bbox=None, **kwargs):
256256
if is_string_like(loc) and loc not in self.codes:
257257
warnings.warn('Unrecognized location %s. Falling back on '
258258
'bottom; valid locations are\n%s\t' %
259-
(loc, '\n\t'.join(six.iterkeys(self.codes))))
259+
(loc, '\n\t'.join(self.codes)))
260260
loc = 'bottom'
261261
if is_string_like(loc):
262262
loc = self.codes.get(loc, 1)
@@ -328,8 +328,7 @@ def _get_grid_bbox(self, renderer):
328328
329329
Only include those in the range (0,0) to (maxRow, maxCol)"""
330330
boxes = [self._cells[pos].get_window_extent(renderer)
331-
for pos in six.iterkeys(self._cells)
332-
if pos[0] >= 0 and pos[1] >= 0]
331+
for pos in self._cells if pos[0] >= 0 and pos[1] >= 0]
333332

334333
bbox = Bbox.union(boxes)
335334
return bbox.inverse_transformed(self.get_transform())
@@ -346,9 +345,9 @@ def contains(self, mouseevent):
346345
# doesn't have to bind to each one individually.
347346
renderer = self.figure._cachedRenderer
348347
if renderer is not None:
349-
boxes = [self._cells[pos].get_window_extent(renderer)
350-
for pos in six.iterkeys(self._cells)
351-
if pos[0] >= 0 and pos[1] >= 0]
348+
boxes = [cell.get_window_extent(renderer)
349+
for (row, col), cell in six.iteritems(self._cells)
350+
if row >= 0 and col >= 0]
352351
bbox = Bbox.union(boxes)
353352
return bbox.contains(mouseevent.x, mouseevent.y), {}
354353
else:

‎lib/matplotlib/testing/compare.py

Copy file name to clipboardExpand all lines: lib/matplotlib/testing/compare.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ def comparable_formats():
157157
on this system.
158158
159159
"""
160-
return ['png'] + list(six.iterkeys(converter))
160+
return ['png'] + list(converter)
161161

162162

163163
def convert(filename, cache):

‎lib/matplotlib/tests/test_colors.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_colors.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,7 @@ def test_pandas_iterable():
624624
def test_colormap_reversing():
625625
"""Check the generated _lut data of a colormap and corresponding
626626
reversed colormap if they are almost the same."""
627-
for name in six.iterkeys(cm.cmap_d):
627+
for name in cm.cmap_d:
628628
cmap = plt.get_cmap(name)
629629
cmap_r = cmap.reversed()
630630
if not cmap_r._isinit:

‎lib/matplotlib/tests/test_rcparams.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_rcparams.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def test_RcParams_class():
113113

114114
# test the find_all functionality
115115
assert ['font.cursive', 'font.size'] == sorted(rc.find_all('i[vz]').keys())
116-
assert ['font.family'] == list(six.iterkeys(rc.find_all('family')))
116+
assert ['font.family'] == list(rc.find_all('family'))
117117

118118

119119
def test_rcparams_update():
@@ -153,7 +153,7 @@ def test_Bug_2543():
153153
category=UserWarning)
154154
with mpl.rc_context():
155155
_copy = mpl.rcParams.copy()
156-
for key in six.iterkeys(_copy):
156+
for key in _copy:
157157
mpl.rcParams[key] = _copy[key]
158158
mpl.rcParams['text.dvipnghack'] = None
159159
with mpl.rc_context():

0 commit comments

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