X Tutup
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions lib/matplotlib/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,13 +297,17 @@ def __copy__(self):

copy = __copy__

def __deepcopy__(self):
def __deepcopy__(self, memo=None):
"""
Returns a deepcopy of the `Path`. The `Path` will not be
readonly, even if the source `Path` is.
"""
try:
codes = self.codes.copy()
except AttributeError:
codes = None
return self.__class__(
self.vertices.copy(), self.codes.copy(),
self.vertices.copy(), codes,
_interpolation_steps=self._interpolation_steps)

deepcopy = __deepcopy__
Expand Down
11 changes: 11 additions & 0 deletions lib/matplotlib/tests/test_path.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import (absolute_import, division, print_function,
unicode_literals)
import copy

import six

Expand Down Expand Up @@ -172,6 +173,16 @@ def test_path_to_polygons():
assert_array_equal(p.to_polygons(closed_only=False), [data])


def test_path_deepcopy():
# Should not raise any error
verts = [[0, 0], [1, 1]]
codes = [Path.MOVETO, Path.LINETO]
path1 = Path(verts)
path2 = Path(verts, codes)
copy.deepcopy(path1)
copy.deepcopy(path2)


if __name__ == '__main__':
import nose
nose.runmodule(argv=['-s', '--with-doctest'], exit=False)
X Tutup