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 b923ef3

Browse filesBrowse files
committed
Simplify pickling support.
- silent_list is directly picklable as is; no need to do anything about it. While we're at it, also get rid of `__str__` -- `__str__` is documented to fall back on `__repr__`, so the latter is sufficient. - When pickling GridSpec and SubplotSpec, set _layoutbox to None, so that no special loading is needed.
1 parent bd1e75a commit b923ef3
Copy full SHA for b923ef3

File tree

Expand file treeCollapse file tree

2 files changed

+2
-32
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+2
-32
lines changed

‎lib/matplotlib/cbook/__init__.py

Copy file name to clipboardExpand all lines: lib/matplotlib/cbook/__init__.py
-10Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -256,16 +256,6 @@ def __init__(self, type, seq=None):
256256
def __repr__(self):
257257
return '<a list of %d %s objects>' % (len(self), self.type)
258258

259-
__str__ = __repr__
260-
261-
def __getstate__(self):
262-
# store a dictionary of this SilentList's state
263-
return {'type': self.type, 'seq': self[:]}
264-
265-
def __setstate__(self, state):
266-
self.type = state['type']
267-
self.extend(state['seq'])
268-
269259

270260
@deprecated("3.3")
271261
class IgnoredKeywordWarning(UserWarning):

‎lib/matplotlib/gridspec.py

Copy file name to clipboardExpand all lines: lib/matplotlib/gridspec.py
+2-22Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -312,17 +312,7 @@ def __init__(self, nrows, ncols, figure=None,
312312
_AllowedKeys = ["left", "bottom", "right", "top", "wspace", "hspace"]
313313

314314
def __getstate__(self):
315-
state = self.__dict__
316-
try:
317-
state.pop('_layoutbox')
318-
except KeyError:
319-
pass
320-
return state
321-
322-
def __setstate__(self, state):
323-
self.__dict__ = state
324-
# layoutboxes don't survive pickling...
325-
self._layoutbox = None
315+
return {**self.__dict__, "_layoutbox": None}
326316

327317
def update(self, **kwargs):
328318
"""
@@ -580,17 +570,7 @@ def num2(self, value):
580570
self._num2 = value
581571

582572
def __getstate__(self):
583-
state = self.__dict__
584-
try:
585-
state.pop('_layoutbox')
586-
except KeyError:
587-
pass
588-
return state
589-
590-
def __setstate__(self, state):
591-
self.__dict__ = state
592-
# layoutboxes don't survive pickling...
593-
self._layoutbox = None
573+
return {**self.__dict__, "_layoutbox": None}
594574

595575
def get_gridspec(self):
596576
return self._gridspec

0 commit comments

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