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 dda3a9a

Browse filesBrowse files
committed
Use builtin copy for shallow copy
1 parent 191452d commit dda3a9a
Copy full SHA for dda3a9a

File tree

Expand file treeCollapse file tree

2 files changed

+13
-20
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+13
-20
lines changed

‎lib/matplotlib/path.py

Copy file name to clipboardExpand all lines: lib/matplotlib/path.py
+3-10Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
visualisation.
1010
"""
1111

12+
import copy
1213
from functools import lru_cache
1314
from weakref import WeakValueDictionary
1415

@@ -259,20 +260,12 @@ def readonly(self):
259260
"""
260261
return self._readonly
261262

262-
def __copy__(self):
263+
def copy(self):
263264
"""
264265
Return a shallow copy of the `Path`, which will share the
265266
vertices and codes with the source `Path`.
266267
"""
267-
try:
268-
codes = self.codes
269-
except AttributeError:
270-
codes = None
271-
return self.__class__(
272-
self.vertices, codes,
273-
_interpolation_steps=self._interpolation_steps)
274-
275-
copy = __copy__
268+
return copy.copy(self)
276269

277270
def __deepcopy__(self, memo=None):
278271
"""

‎lib/matplotlib/tests/test_path.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_path.py
+10-10Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -334,11 +334,11 @@ def test_path_deepcopy():
334334
path2 = Path(verts, codes)
335335
path1_copy = path1.deepcopy()
336336
path2_copy = path2.deepcopy()
337-
assert(path1 is not path1_copy)
338-
assert(path1.vertices is not path1_copy.vertices)
339-
assert(path2 is not path2_copy)
340-
assert(path2.vertices is not path2_copy.vertices)
341-
assert(path2.codes is not path2_copy.codes)
337+
assert path1 is not path1_copy
338+
assert path1.vertices is not path1_copy.vertices
339+
assert path2 is not path2_copy
340+
assert path2.vertices is not path2_copy.vertices
341+
assert path2.codes is not path2_copy.codes
342342

343343

344344
def test_path_shallowcopy():
@@ -349,11 +349,11 @@ def test_path_shallowcopy():
349349
path2 = Path(verts, codes)
350350
path1_copy = path1.copy()
351351
path2_copy = path2.copy()
352-
assert(path1 is not path1_copy)
353-
assert(path1.vertices is path1_copy.vertices)
354-
assert(path2 is not path2_copy)
355-
assert(path2.vertices is path2_copy.vertices)
356-
assert(path2.codes is path2_copy.codes)
352+
assert path1 is not path1_copy
353+
assert path1.vertices is path1_copy.vertices
354+
assert path2 is not path2_copy
355+
assert path2.vertices is path2_copy.vertices
356+
assert path2.codes is path2_copy.codes
357357

358358

359359
@pytest.mark.parametrize('phi', np.concatenate([

0 commit comments

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