Fixed Image and Renderer pickling by pelson · Pull Request #3627 · matplotlib/matplotlib · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lib/matplotlib/backends/backend_agg.py
8 changes: 6 additions & 2 deletions lib/matplotlib/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@

import os
import warnings
import math

import numpy as np
from numpy import ma

from matplotlib import rcParams
import matplotlib.artist as martist
Expand Down Expand Up @@ -113,6 +111,12 @@ def __init__(self, ax,

self.update(kwargs)

def __getstate__(self):
state = super(_AxesImageBase, self).__getstate__()
# We can't pickle the C Image cached object.
state.pop('_imcache', None)
return state

def get_size(self):
"""Get the numrows, numcols of the input image"""
if self._A is None:
Expand Down
6 changes: 6 additions & 0 deletions lib/matplotlib/lines.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,12 @@ def __init__(self, xdata, ydata,
self._invalidy = True
self.set_data(xdata, ydata)

def __getstate__(self):
state = super(Line2D, self).__getstate__()
# _linefunc will be restored on draw time.
state.pop('_lineFunc', None)
return state

def contains(self, mouseevent):
"""
Test whether the mouse event occurred on the line. The pick
Expand Down
46 changes: 39 additions & 7 deletions lib/matplotlib/tests/test_pickle.py