Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
tsoc
openmm
Commits
9c7c79a1
Commit
9c7c79a1
authored
Oct 01, 2014
by
kyleabeauchamp
Browse files
Added pickler for integrators and test.
parent
168aaa49
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
2 deletions
+14
-2
wrappers/python/src/swig_doxygen/swig_lib/python/extend.i
wrappers/python/src/swig_doxygen/swig_lib/python/extend.i
+12
-0
wrappers/python/tests/TestPickle.py
wrappers/python/tests/TestPickle.py
+2
-2
No files found.
wrappers/python/src/swig_doxygen/swig_lib/python/extend.i
View file @
9c7c79a1
...
@@ -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
}
}
wrappers/python/tests/TestPickle.py
View file @
9c7c79a1
...
@@ -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
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment