Skip to content

Commit fa45df6

Browse files
committed
Cleanup list copying
1 parent 5d660a4 commit fa45df6

File tree

6 files changed

+20
-17
lines changed

6 files changed

+20
-17
lines changed

doc/sphinxext/missing_references.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ def prepare_missing_references_handler(app):
254254

255255
sphinx_logger = logging.getLogger('sphinx')
256256
missing_reference_filter = MissingReferenceFilter(app)
257-
for handler in sphinx_logger.handlers[:]:
257+
for handler in sphinx_logger.handlers:
258258
if (isinstance(handler, sphinx_logging.WarningStreamHandler)
259259
and missing_reference_filter not in handler.filters):
260260

lib/matplotlib/artist.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1065,8 +1065,8 @@ def update_from(self, other):
10651065
self._label = other._label
10661066
self._sketch = other._sketch
10671067
self._path_effects = other._path_effects
1068-
self.sticky_edges.x[:] = other.sticky_edges.x[:]
1069-
self.sticky_edges.y[:] = other.sticky_edges.y[:]
1068+
self.sticky_edges.x[:] = other.sticky_edges.x.copy()
1069+
self.sticky_edges.y[:] = other.sticky_edges.y.copy()
10701070
self.pchanged()
10711071
self.stale = True
10721072

lib/matplotlib/backend_bases.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,9 @@ def draw_gouraud_triangle(self, gc, points, colors, transform):
258258
259259
Parameters
260260
----------
261+
gc : `.GraphicsContextBase`
262+
The graphics context.
263+
261264
points : array-like, shape=(3, 2)
262265
Array of (x, y) points for the triangle.
263266
@@ -1059,7 +1062,7 @@ def __init__(self, interval=None, callbacks=None):
10591062
if callbacks is None:
10601063
self.callbacks = []
10611064
else:
1062-
self.callbacks = callbacks[:] # Create a copy
1065+
self.callbacks = callbacks.copy()
10631066

10641067
if interval is None:
10651068
self._interval = 1000

lib/matplotlib/backends/backend_svg.py

+10-7
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,8 @@ def draw_path_collection(self, gc, master_transform, paths, all_transforms,
650650
self._path_collection_id += 1
651651

652652
def draw_gouraud_triangle(self, gc, points, colors, trans):
653+
# docstring inherited
654+
653655
# This uses a method described here:
654656
#
655657
# http://www.svgopen.org/2005/papers/Converting3DFaceToSVG/index.html
@@ -685,9 +687,9 @@ def draw_gouraud_triangle(self, gc, points, colors, trans):
685687
' \n1 1 1 1 0 \n0 0 0 0 1 ')
686688
writer.end('filter')
687689

688-
avg_color = np.sum(colors[:, :], axis=0) / 3.0
689-
# Just skip fully-transparent triangles
690-
if avg_color[-1] == 0.0:
690+
avg_color = np.average(colors, axis=0)
691+
if avg_color[-1] == 0:
692+
# Skip fully-transparent triangles
691693
return
692694

693695
trans_and_flip = self._make_flip_transform(trans)
@@ -698,7 +700,7 @@ def draw_gouraud_triangle(self, gc, points, colors, trans):
698700
x1, y1 = tpoints[i]
699701
x2, y2 = tpoints[(i + 1) % 3]
700702
x3, y3 = tpoints[(i + 2) % 3]
701-
c = colors[i][:]
703+
rgba_color = colors[i]
702704

703705
if x2 == x3:
704706
xb = x2
@@ -723,12 +725,13 @@ def draw_gouraud_triangle(self, gc, points, colors, trans):
723725
writer.element(
724726
'stop',
725727
offset='1',
726-
style=generate_css({'stop-color': rgb2hex(avg_color),
727-
'stop-opacity': short_float_fmt(c[-1])}))
728+
style=generate_css({
729+
'stop-color': rgb2hex(avg_color),
730+
'stop-opacity': short_float_fmt(rgba_color[-1])}))
728731
writer.element(
729732
'stop',
730733
offset='0',
731-
style=generate_css({'stop-color': rgb2hex(c),
734+
style=generate_css({'stop-color': rgb2hex(rgba_color),
732735
'stop-opacity': "0"}))
733736

734737
writer.end('linearGradient')

lib/matplotlib/patches.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -3159,11 +3159,8 @@ def __call__(self, path, mutation_size, linewidth,
31593159

31603160
if aspect_ratio is not None:
31613161
# Squeeze the given height by the aspect_ratio
3162-
3163-
vertices, codes = path.vertices[:], path.codes[:]
3164-
# Squeeze the height
3165-
vertices[:, 1] = vertices[:, 1] / aspect_ratio
3166-
path_shrunk = Path(vertices, codes)
3162+
vertices = path.vertices / [1, aspect_ratio]
3163+
path_shrunk = Path(vertices, path.codes.copy())
31673164
# call transmute method with squeezed height.
31683165
path_mutated, fillable = self.transmute(path_shrunk,
31693166
linewidth,

lib/matplotlib/widgets.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2578,7 +2578,7 @@ def _press(self, event):
25782578
self._active_handle_idx = h_idx
25792579
# Save the vertex positions at the time of the press event (needed to
25802580
# support the 'move_all' state modifier).
2581-
self._xs_at_press, self._ys_at_press = self._xs[:], self._ys[:]
2581+
self._xs_at_press, self._ys_at_press = self._xs.copy(), self._ys.copy()
25822582

25832583
def _release(self, event):
25842584
"""Button release event handler"""

0 commit comments

Comments
 (0)