Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commitf765d04

Browse files
committed
Use builtin copy for shallow copy
1 parent191452d commitf765d04

File tree

2 files changed

+14
-21
lines changed

2 files changed

+14
-21
lines changed

‎lib/matplotlib/path.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
visualisation.
1010
"""
1111

12+
importcopy
1213
fromfunctoolsimportlru_cache
1314
fromweakrefimportWeakValueDictionary
1415

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

262-
def__copy__(self):
263+
defcopy(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-
exceptAttributeError:
270-
codes=None
271-
returnself.__class__(
272-
self.vertices,codes,
273-
_interpolation_steps=self._interpolation_steps)
274-
275-
copy=__copy__
268+
returncopy.copy(self)
276269

277270
def__deepcopy__(self,memo=None):
278271
"""
@@ -288,7 +281,7 @@ def __deepcopy__(self, memo=None):
288281
_interpolation_steps=self._interpolation_steps)
289282

290283
deepcopy=__deepcopy__
291-
284+
292285
@classmethod
293286
defmake_compound_path_from_polys(cls,XY):
294287
"""

‎lib/matplotlib/tests/test_path.py

Lines 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(path1isnotpath1_copy)
338-
assert(path1.verticesisnotpath1_copy.vertices)
339-
assert(path2isnotpath2_copy)
340-
assert(path2.verticesisnotpath2_copy.vertices)
341-
assert(path2.codesisnotpath2_copy.codes)
337+
assertpath1isnotpath1_copy
338+
assertpath1.verticesisnotpath1_copy.vertices
339+
assertpath2isnotpath2_copy
340+
assertpath2.verticesisnotpath2_copy.vertices
341+
assertpath2.codesisnotpath2_copy.codes
342342

343343

344344
deftest_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(path1isnotpath1_copy)
353-
assert(path1.verticesispath1_copy.vertices)
354-
assert(path2isnotpath2_copy)
355-
assert(path2.verticesispath2_copy.vertices)
356-
assert(path2.codesispath2_copy.codes)
352+
assertpath1isnotpath1_copy
353+
assertpath1.verticesispath1_copy.vertices
354+
assertpath2isnotpath2_copy
355+
assertpath2.verticesispath2_copy.vertices
356+
assertpath2.codesispath2_copy.codes
357357

358358

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp