Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5478183

Browse files
committed
BUG: Avoid set_children when unpickling TransformWrapper.
Calling set_children may or may not work if the child has been unpickled yet, and it actually causes duplicate parents to be set in the times when it does appear to work.
1 parent b9bc7d1 commit 5478183

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

lib/matplotlib/transforms.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1533,6 +1533,10 @@ def __init__(self, child):
15331533
msg = ("'child' must be an instance of"
15341534
" 'matplotlib.transform.Transform'")
15351535
raise ValueError(msg)
1536+
self._init(child)
1537+
self.set_children(child)
1538+
1539+
def _init(self, child):
15361540
Transform.__init__(self)
15371541
self.input_dims = child.input_dims
15381542
self.output_dims = child.output_dims
@@ -1553,7 +1557,7 @@ def __getstate__(self):
15531557

15541558
def __setstate__(self, state):
15551559
# re-initialise the TransformWrapper with the state's child
1556-
self.__init__(state['child'])
1560+
self._init(state['child'])
15571561

15581562
def __repr__(self):
15591563
return "TransformWrapper(%r)" % self._child
@@ -1564,7 +1568,6 @@ def frozen(self):
15641568

15651569
def _set(self, child):
15661570
self._child = child
1567-
self.set_children(child)
15681571

15691572
self.transform = child.transform
15701573
self.transform_affine = child.transform_affine
@@ -1593,6 +1596,7 @@ def set(self, child):
15931596
" output dimensions as the current child.")
15941597
raise ValueError(msg)
15951598

1599+
self.set_children(child)
15961600
self._set(child)
15971601

15981602
self._invalid = 0

0 commit comments

Comments
 (0)