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
9639837c
Commit
9639837c
authored
Oct 26, 2015
by
John Chodera (MSKCC)
Browse files
Add Python test to catch force deepcopy bug
parent
8eaf3c9c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
7 deletions
+11
-7
wrappers/python/tests/TestPickle.py
wrappers/python/tests/TestPickle.py
+11
-7
No files found.
wrappers/python/tests/TestPickle.py
View file @
9639837c
...
@@ -9,7 +9,7 @@ import copy
...
@@ -9,7 +9,7 @@ import copy
import
pickle
import
pickle
class
TestPickle
(
unittest
.
TestCase
):
class
TestPickle
(
unittest
.
TestCase
):
"""Pickling / deepcopy of OpenMM
state and integrator
objects."""
"""Pickling / deepcopy of OpenMM objects."""
def
setUp
(
self
):
def
setUp
(
self
):
"""Set up the tests by loading the input pdb files and force field
"""Set up the tests by loading the input pdb files and force field
...
@@ -26,9 +26,8 @@ class TestPickle(unittest.TestCase):
...
@@ -26,9 +26,8 @@ class TestPickle(unittest.TestCase):
self
.
pdb2
=
PDBFile
(
'systems/alanine-dipeptide-implicit.pdb'
)
self
.
pdb2
=
PDBFile
(
'systems/alanine-dipeptide-implicit.pdb'
)
self
.
forcefield2
=
ForceField
(
'amber99sb.xml'
,
'amber99_obc.xml'
)
self
.
forcefield2
=
ForceField
(
'amber99sb.xml'
,
'amber99_obc.xml'
)
def
test_system_integrator_deepcopy
(
self
):
def
test_deepcopy
(
self
):
"""Test that serialization/deserialization of system and integrator works (via deepcopy)."""
"""Test that serialization/deserialization works (via deepcopy)."""
system
=
self
.
forcefield1
.
createSystem
(
self
.
pdb1
.
topology
)
system
=
self
.
forcefield1
.
createSystem
(
self
.
pdb1
.
topology
)
integrator
=
VerletIntegrator
(
2
*
femtosecond
)
integrator
=
VerletIntegrator
(
2
*
femtosecond
)
...
@@ -46,9 +45,14 @@ class TestPickle(unittest.TestCase):
...
@@ -46,9 +45,14 @@ class TestPickle(unittest.TestCase):
state3
=
pickle
.
loads
(
str_state
)
state3
=
pickle
.
loads
(
str_state
)
context
.
setState
(
state3
)
context
.
setState
(
state3
)
del
context
,
integrator
del
context
,
integrator
def
test_force_deepcopy
(
self
):
"""Test that deep copying of forces works correctly."""
force
=
NonbondedForce
()
force_copy
=
copy
.
deepcopy
(
force
)
self
.
assertIsEqual
(
force
.
__class__
.
__name__
,
'NonbondedForce'
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
unittest
.
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