From: W. Trevor King Date: Fri, 4 Jun 2010 14:40:17 +0000 (-0400) Subject: Adjust hooke.curve.Data so .info is picklable. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=03f133b884501a8e5334097351438d8a34a8fe87;p=hooke.git Adjust hooke.curve.Data so .info is picklable. Otherwise it didn't survive the Queue between the UI and Engine processes. See http://mail.scipy.org/pipermail/numpy-discussion/2007-April/027193.html --- diff --git a/hooke/curve.py b/hooke/curve.py index bd58a18..1b30bfa 100644 --- a/hooke/curve.py +++ b/hooke/curve.py @@ -88,6 +88,16 @@ class Data (numpy.ndarray): self.info = getattr(obj, 'info', {}) # We do not need to return anything + def __reduce__(self): + base_class_state = list(numpy.ndarray.__reduce__(self)) + own_state = (self.info,) + return (base_class_state, own_state) + + def __setstate__(self,state): + base_class_state,own_state = state + numpy.ndarray.__setstate__(self, base_class_state) + self.info, = own_state + class Curve (object): """A grouped set of :class:`Data` runs from the same file with metadata.