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
771842ac
Commit
771842ac
authored
Oct 01, 2014
by
kyleabeauchamp
Browse files
Added test for python serialize
parent
252bf5c7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
0 deletions
+54
-0
wrappers/python/tests/TestSerialize.py
wrappers/python/tests/TestSerialize.py
+54
-0
No files found.
wrappers/python/tests/TestSerialize.py
0 → 100644
View file @
771842ac
import
unittest
from
validateConstraints
import
*
from
simtk.openmm.app
import
*
from
simtk.openmm
import
*
from
simtk.unit
import
*
import
simtk.openmm.app.element
as
elem
import
simtk.openmm.app.forcefield
as
forcefield
import
copy
import
pickle
class
TestSerialize
(
unittest
.
TestCase
):
"""Test serialization wrappers in Python."""
def
setUp
(
self
):
"""Set up the tests by loading the input pdb files and force field
xml files.
"""
# alanine dipeptide with explicit water
self
.
pdb1
=
PDBFile
(
'systems/alanine-dipeptide-explicit.pdb'
)
self
.
forcefield1
=
ForceField
(
'amber99sb.xml'
,
'tip3p.xml'
)
self
.
topology1
=
self
.
pdb1
.
topology
self
.
topology1
.
setUnitCellDimensions
(
Vec3
(
2
,
2
,
2
))
# alalnine dipeptide with implicit water
self
.
pdb2
=
PDBFile
(
'systems/alanine-dipeptide-implicit.pdb'
)
self
.
forcefield2
=
ForceField
(
'amber99sb.xml'
,
'amber99_obc.xml'
)
def
test_deepcopy
(
self
):
"""Test that serialization/deserialization works (via deepcopy)."""
system
=
self
.
forcefield1
.
createSystem
(
self
.
pdb1
.
topology
)
integrator
=
VerletIntegrator
(
2
*
femtosecond
)
context
=
Context
(
system
,
integrator
)
context
.
setPositions
(
self
.
pdb1
.
positions
)
state
=
context
.
getState
(
getPositions
=
True
,
getForces
=
True
,
getEnergy
=
True
)
system2
=
copy
.
deepcopy
(
system
)
#integrator2 = copy.deepcopy(integrator)
state2
=
copy
.
deepcopy
(
state
)
str_state
=
pickle
.
dumps
(
state
)
#str_integrator = pickle.dumps(integrator)
state3
=
pickle
.
loads
(
str_state
)
context
.
setState
(
state3
)
del
context
,
integrator
if
__name__
==
'__main__'
:
unittest
.
main
()
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