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 5b41e5e

Browse filesBrowse files
authored
Merge pull request #13338 from anntzer/unextend
Replace list.extend by star-expansion or other constructs.
2 parents 6ec75f5 + 8a730b4 commit 5b41e5e
Copy full SHA for 5b41e5e

File tree

Expand file treeCollapse file tree

8 files changed

+43
-59
lines changed
Filter options
Expand file treeCollapse file tree

8 files changed

+43
-59
lines changed

‎lib/matplotlib/axis.py

Copy file name to clipboardExpand all lines: lib/matplotlib/axis.py
+2-7Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -835,13 +835,8 @@ def limit_range_for_scale(self, vmin, vmax):
835835
return self._scale.limit_range_for_scale(vmin, vmax, self.get_minpos())
836836

837837
def get_children(self):
838-
children = [self.label, self.offsetText]
839-
majorticks = self.get_major_ticks()
840-
minorticks = self.get_minor_ticks()
841-
842-
children.extend(majorticks)
843-
children.extend(minorticks)
844-
return children
838+
return [self.label, self.offsetText,
839+
*self.get_major_ticks(), *self.get_minor_ticks()]
845840

846841
def cla(self):
847842
'clear the current axis'

‎lib/matplotlib/backends/backend_pdf.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/backend_pdf.py
+7-9Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -178,18 +178,16 @@ def pdfRepr(obj):
178178
# anything, so the caller must ensure that PDF names are
179179
# represented as Name objects.
180180
elif isinstance(obj, dict):
181-
r = [b"<<"]
182-
r.extend([Name(key).pdfRepr() + b" " + pdfRepr(obj[key])
183-
for key in sorted(obj)])
184-
r.append(b">>")
185-
return fill(r)
181+
return fill([
182+
b"<<",
183+
*[Name(key).pdfRepr() + b" " + pdfRepr(obj[key])
184+
for key in sorted(obj)],
185+
b">>",
186+
])
186187

187188
# Lists.
188189
elif isinstance(obj, (list, tuple)):
189-
r = [b"["]
190-
r.extend([pdfRepr(val) for val in obj])
191-
r.append(b"]")
192-
return fill(r)
190+
return fill([b"[", *[pdfRepr(val) for val in obj], b"]"])
193191

194192
# The null keyword.
195193
elif obj is None:

‎lib/matplotlib/backends/backend_ps.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/backend_ps.py
+17-10Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -398,11 +398,15 @@ def _get_clip_path(self, clippath, clippath_transform):
398398
pid = self._clip_paths.get(key)
399399
if pid is None:
400400
pid = 'c%x' % len(self._clip_paths)
401-
ps_cmd = ['/%s {' % pid]
402-
ps_cmd.append(self._convert_path(clippath, clippath_transform,
403-
simplify=False))
404-
ps_cmd.extend(['clip', 'newpath', '} bind def\n'])
405-
self._pswriter.write('\n'.join(ps_cmd))
401+
clippath_bytes = self._convert_path(
402+
clippath, clippath_transform, simplify=False)
403+
self._pswriter.write(f"""\
404+
/{pid} {{
405+
{clippath_bytes}
406+
clip
407+
newpath
408+
}} bind def
409+
""")
406410
self._clip_paths[key] = pid
407411
return pid
408412

@@ -497,11 +501,14 @@ def draw_path_collection(self, gc, master_transform, paths, all_transforms,
497501
for i, (path, transform) in enumerate(self._iter_collection_raw_paths(
498502
master_transform, paths, all_transforms)):
499503
name = 'p%x_%x' % (self._path_collection_id, i)
500-
ps_cmd = ['/%s {' % name,
501-
'newpath', 'translate']
502-
ps_cmd.append(self._convert_path(path, transform, simplify=False))
503-
ps_cmd.extend(['} bind def\n'])
504-
write('\n'.join(ps_cmd))
504+
path_bytes = self._convert_path(path, transform, simplify=False)
505+
write(f"""\
506+
/{name} {{
507+
newpath
508+
translate
509+
{path_bytes}
510+
}} bind def
511+
""")
505512
path_codes.append(name)
506513

507514
for xo, yo, path_id, gc0, rgbFace in self._iter_collection(

‎lib/matplotlib/contour.py

Copy file name to clipboardExpand all lines: lib/matplotlib/contour.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -602,8 +602,8 @@ def labels(self, inline, inline_spacing):
602602
else: # If not adding label, keep old path
603603
additions.append(linepath)
604604

605-
# After looping over all segments on a contour, remove old
606-
# paths and add new ones if inlining
605+
# After looping over all segments on a contour, replace old paths
606+
# by new ones if inlining.
607607
if inline:
608608
paths[:] = additions
609609

‎lib/matplotlib/legend_handler.py

Copy file name to clipboardExpand all lines: lib/matplotlib/legend_handler.py
+4-12Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -536,15 +536,11 @@ def create_artists(self, legend, orig_handle,
536536
handle_caplines.append(capline_left)
537537
handle_caplines.append(capline_right)
538538

539-
artists = []
540-
artists.extend(handle_barlinecols)
541-
artists.extend(handle_caplines)
542-
artists.append(legline)
543-
artists.append(legline_marker)
544-
539+
artists = [
540+
*handle_barlinecols, *handle_caplines, legline, legline_marker,
541+
]
545542
for artist in artists:
546543
artist.set_transform(trans)
547-
548544
return artists
549545

550546

@@ -634,13 +630,9 @@ def create_artists(self, legend, orig_handle,
634630
[bottom, bottom])
635631
self.update_prop(leg_baseline, baseline, legend)
636632

637-
artists = leg_stemlines
638-
artists.append(leg_baseline)
639-
artists.append(leg_markerline)
640-
633+
artists = [*leg_stemlines, leg_baseline, leg_markerline]
641634
for artist in artists:
642635
artist.set_transform(trans)
643-
644636
return artists
645637

646638
def _copy_collection_props(self, legend_handle, orig_handle):

‎lib/matplotlib/text.py

Copy file name to clipboardExpand all lines: lib/matplotlib/text.py
+3-5Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1377,11 +1377,9 @@ def get_prop_tup(self, renderer=None):
13771377
want to cache derived information about text (e.g., layouts) and
13781378
need to know if the text has changed.
13791379
"""
1380-
props = [p for p in Text.get_prop_tup(self, renderer=renderer)]
1381-
props.extend([self._x, self._y, self._dashlength,
1382-
self._dashdirection, self._dashrotation, self._dashpad,
1383-
self._dashpush])
1384-
return tuple(props)
1380+
return (*Text.get_prop_tup(self, renderer=renderer),
1381+
self._x, self._y, self._dashlength, self._dashdirection,
1382+
self._dashrotation, self._dashpad, self._dashpush)
13851383

13861384
def draw(self, renderer):
13871385
"""

‎lib/mpl_toolkits/axisartist/axis_artist.py

Copy file name to clipboardExpand all lines: lib/mpl_toolkits/axisartist/axis_artist.py
+6-10Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1232,18 +1232,14 @@ def get_tightbbox(self, renderer):
12321232
dpi_cor = renderer.points_to_pixels(1.)
12331233
self.dpi_transform.clear().scale(dpi_cor, dpi_cor)
12341234

1235-
bb = []
1236-
12371235
self._update_ticks(renderer)
1238-
1239-
bb.extend(self.major_ticklabels.get_window_extents(renderer))
1240-
bb.extend(self.minor_ticklabels.get_window_extents(renderer))
1241-
12421236
self._update_label(renderer)
1243-
1244-
bb.append(self.label.get_window_extent(renderer))
1245-
bb.append(self.offsetText.get_window_extent(renderer))
1246-
1237+
bb = [
1238+
*self.major_ticklabels.get_window_extents(renderer),
1239+
*self.minor_ticklabels.get_window_extents(renderer),
1240+
self.label.get_window_extent(renderer),
1241+
self.offsetText.get_window_extent(renderer),
1242+
]
12471243
bb = [b for b in bb if b and (b.width != 0 or b.height != 0)]
12481244
if bb:
12491245
_bbox = Bbox.union(bb)

‎lib/mpl_toolkits/axisartist/floating_axes.py

Copy file name to clipboardExpand all lines: lib/mpl_toolkits/axisartist/floating_axes.py
+2-4Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -287,11 +287,9 @@ def _update_grid(self, x1, y1, x2, y2):
287287
def get_gridlines(self, which="major", axis="both"):
288288
grid_lines = []
289289
if axis in ["both", "x"]:
290-
for gl in self.grid_info["lon_lines"]:
291-
grid_lines.extend([gl])
290+
grid_lines.extend(self.grid_info["lon_lines"])
292291
if axis in ["both", "y"]:
293-
for gl in self.grid_info["lat_lines"]:
294-
grid_lines.extend([gl])
292+
grid_lines.extend(self.grid_info["lat_lines"])
295293
return grid_lines
296294

297295
def get_boundary(self):

0 commit comments

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