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 5c9041f

Browse filesBrowse files
committed
Merge pull request #5376 from QuLogic/transformwrapper-pickles-redux
Fix TransformWrapper pickles (take 2)
2 parents 3909c5b + fdba8ec commit 5c9041f
Copy full SHA for 5c9041f

File tree

Expand file treeCollapse file tree

2 files changed

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

2 files changed

+11
-1
lines changed

‎lib/matplotlib/tests/test_pickle.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_pickle.py
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,9 @@ def test_transform():
279279
assert_equal(obj.wrapper._child, obj.composite)
280280
# Check child -> parent links of TransformWrapper.
281281
assert_equal(list(obj.wrapper._parents.values()), [obj.composite2])
282+
# Check input and output dimensions are set as expected.
283+
assert_equal(obj.wrapper.input_dims, obj.composite.input_dims)
284+
assert_equal(obj.wrapper.output_dims, obj.composite.output_dims)
282285

283286

284287
if __name__ == '__main__':

‎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.