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 fdba8ec

Browse filesBrowse files
committed
FIX: Explicitly pickle dims in TransformWrapper.
Unpckling does not seem to guarantee the order in which _state_ is restored, so copying values from the child transform may result in garbage state if the child's state has not yet been restored.
1 parent ac7377c commit fdba8ec
Copy full SHA for fdba8ec

File tree

Expand file treeCollapse file tree

1 file changed

+8
-1
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+8
-1
lines changed

‎lib/matplotlib/transforms.py

Copy file name to clipboardExpand all lines: lib/matplotlib/transforms.py
+8-1Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1552,17 +1552,24 @@ def __eq__(self, other):
15521552
def __str__(self):
15531553
return str(self._child)
15541554

1555+
# NOTE: Transform.__[gs]etstate__ should be sufficient when using only
1556+
# Python 3.4+.
15551557
def __getstate__(self):
1556-
# only store the child and parents
1558+
# only store the child information and parents
15571559
return {
15581560
'child': self._child,
1561+
'input_dims': self.input_dims,
1562+
'output_dims': self.output_dims,
15591563
# turn the weakkey dictionary into a normal dictionary
15601564
'parents': dict(six.iteritems(self._parents))
15611565
}
15621566

15631567
def __setstate__(self, state):
15641568
# re-initialise the TransformWrapper with the state's child
15651569
self._init(state['child'])
1570+
# The child may not be unpickled yet, so restore its information.
1571+
self.input_dims = state['input_dims']
1572+
self.output_dims = state['output_dims']
15661573
# turn the normal dictionary back into a WeakValueDictionary
15671574
self._parents = WeakValueDictionary(state['parents'])
15681575

0 commit comments

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