Adjust hooke.curve.Data so .info is picklable.
authorW. Trevor King <wking@drexel.edu>
Fri, 4 Jun 2010 14:40:17 +0000 (10:40 -0400)
committerW. Trevor King <wking@drexel.edu>
Fri, 4 Jun 2010 14:40:17 +0000 (10:40 -0400)
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

hooke/curve.py

index bd58a18f7a663089deb1b5eafaf456c0d43d9013..1b30bfaa4e20cbb1e2dd7ec61906ffafc5efd272 100644 (file)
@@ -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.