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

Skip to content

Commit 353d8f1

Browse files
committed
BUG: Also pickle TransformWrapper's parents.
Pickling would lose track of the parents for a TransformWrapper because of the override of grandparent's pickling methods.
1 parent 83f4b5c commit 353d8f1

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

lib/matplotlib/transforms.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1552,12 +1552,18 @@ def __str__(self):
15521552
return str(self._child)
15531553

15541554
def __getstate__(self):
1555-
# only store the child
1556-
return {'child': self._child}
1555+
# only store the child and parents
1556+
return {
1557+
'child': self._child,
1558+
# turn the weakkey dictionary into a normal dictionary
1559+
'parents': dict(six.iteritems(self._parents))
1560+
}
15571561

15581562
def __setstate__(self, state):
15591563
# re-initialise the TransformWrapper with the state's child
15601564
self._init(state['child'])
1565+
# turn the normal dictionary back into a WeakValueDictionary
1566+
self._parents = WeakValueDictionary(state['parents'])
15611567

15621568
def __repr__(self):
15631569
return "TransformWrapper(%r)" % self._child

0 commit comments

Comments
 (0)