From 95bdc8c6b5b9f111aab92bdbc652feadb06d9a9b Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Mon, 16 Aug 2010 14:59:27 -0400 Subject: [PATCH] Don't save Curve._hooke when pickling or deepcopying. Two reasons: 1) It crashes because hooke.config._comment_textwrap contains a compiled regexp, and these cannot be deepcopied. See http://mail.python.org/pipermail/python-dev/2008-November/083348.html http://bugs.python.org/issue416670 2) We don't want to copy Hooke instances anyway, since we need them to stay in sync. Anything copying curves (e.g. Playlist.filter) should shallow copy Hooke instances between the curves. If this turns up anywhere else, we should think about adding a Curve.copy method to get the "just right" copy depth ;). --- hooke/curve.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/hooke/curve.py b/hooke/curve.py index ed76c8a..a87a7fd 100644 --- a/hooke/curve.py +++ b/hooke/curve.py @@ -41,6 +41,7 @@ class NotRecognized (ValueError): super(NotRecognized, self).__init__(msg) self.curve = data + class Data (numpy.ndarray): """Stores a single, continuous data set. @@ -183,6 +184,16 @@ class Curve (object): def __repr__(self): return self.__str__() + def __getstate__(self): + data = dict(self.__dict__) + del(data['_hooke']) + return data + + def __setstate__(self, data): + self._hooke = None + for key,value in data.items(): + setattr(self, key, value) + def set_hooke(self, hooke=None): if hooke != None: self._hooke = hooke -- 2.26.2