Commit 9c7c79a1 authored by kyleabeauchamp's avatar kyleabeauchamp
Browse files

Added pickler for integrators and test.

parent 168aaa49
...@@ -454,3 +454,15 @@ Parameters: ...@@ -454,3 +454,15 @@ Parameters:
return self.__copy__() return self.__copy__()
} }
} }
%extend OpenMM::Integrator {
%pythoncode {
def __getstate__(self):
serializationString = XmlSerializer.serialize(self)
return serializationString
def __setstate__(self, serializationString):
system = XmlSerializer.deserialize(serializationString)
self.this = system.this
}
}
...@@ -37,11 +37,11 @@ class TestPickle(unittest.TestCase): ...@@ -37,11 +37,11 @@ class TestPickle(unittest.TestCase):
state = context.getState(getPositions=True, getForces=True, getEnergy=True) state = context.getState(getPositions=True, getForces=True, getEnergy=True)
system2 = copy.deepcopy(system) system2 = copy.deepcopy(system)
#integrator2 = copy.deepcopy(integrator) integrator2 = copy.deepcopy(integrator)
state2 = copy.deepcopy(state) state2 = copy.deepcopy(state)
str_state = pickle.dumps(state) str_state = pickle.dumps(state)
#str_integrator = pickle.dumps(integrator) str_integrator = pickle.dumps(integrator)
state3 = pickle.loads(str_state) state3 = pickle.loads(str_state)
context.setState(state3) context.setState(state3)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment