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
9c866ca1
Unverified
Commit
9c866ca1
authored
Dec 04, 2017
by
peastman
Committed by
GitHub
Dec 04, 2017
Browse files
Merge pull request #1948 from Lnaden/bond_py27_pickle
Fix Bond pickling in Python 2.7
parents
07c1b86c
f8624c4e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
0 deletions
+8
-0
wrappers/python/simtk/openmm/app/topology.py
wrappers/python/simtk/openmm/app/topology.py
+8
-0
No files found.
wrappers/python/simtk/openmm/app/topology.py
View file @
9c866ca1
...
...
@@ -465,6 +465,14 @@ class Bond(namedtuple('Bond', ['atom1', 'atom2'])):
"Support for pickle protocol 2: http://docs.python.org/2/library/pickle.html#pickling-and-unpickling-normal-class-instances"
return
self
[
0
],
self
[
1
],
self
.
type
,
self
.
order
def
__getstate__
(
self
):
"""
Additional support for pickle since parent class implements its own __getstate__
so pickle does not store or restore the type and order, python 2 problem only
https://www.python.org/dev/peps/pep-0307/#case-3-pickling-new-style-class-instances-using-protocol-2
"""
return
self
.
__dict__
def
__deepcopy__
(
self
,
memo
):
return
Bond
(
self
[
0
],
self
[
1
],
self
.
type
,
self
.
order
)
...
...
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