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
efa09228
Commit
efa09228
authored
Apr 17, 2013
by
Peter Eastman
Browse files
Context.setState() works in Python
parent
c4e9dcd2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
3 deletions
+28
-3
wrappers/python/src/swig_doxygen/swigInputConfig.py
wrappers/python/src/swig_doxygen/swigInputConfig.py
+1
-0
wrappers/python/src/swig_doxygen/swig_lib/python/extend.i
wrappers/python/src/swig_doxygen/swig_lib/python/extend.i
+27
-3
No files found.
wrappers/python/src/swig_doxygen/swigInputConfig.py
View file @
efa09228
...
@@ -123,6 +123,7 @@ SKIP_METHODS = [('State',),
...
@@ -123,6 +123,7 @@ SKIP_METHODS = [('State',),
(
'VdwInfo'
,),
(
'VdwInfo'
,),
(
'WcaDispersionInfo'
,),
(
'WcaDispersionInfo'
,),
(
'Context'
,
'getState'
),
(
'Context'
,
'getState'
),
(
'Context'
,
'setState'
),
(
'Context'
,
'createCheckpoint'
),
(
'Context'
,
'createCheckpoint'
),
(
'Context'
,
'loadCheckpoint'
),
(
'Context'
,
'loadCheckpoint'
),
(
'CudaPlatform'
,),
(
'CudaPlatform'
,),
...
...
wrappers/python/src/swig_doxygen/swig_lib/python/extend.i
View file @
efa09228
...
@@ -77,14 +77,38 @@
...
@@ -77,14 +77,38 @@
periodicBoxVectorsList
=
periodicBoxVectorsList
,
periodicBoxVectorsList
=
periodicBoxVectorsList
,
paramMap
=
paramMap
)
paramMap
=
paramMap
)
return
state
return
state
}
def
setState
(
self
,
state
)
:
"""
setState(Context self, State state)
Copy information from a State object into this Context. This restores the Context to
approximately the same state it was in when the State was created. If the State does not include
a piece of information (e.g. positions or velocities), that aspect of the Context is
left unchanged.
%
feature
(
"docstring"
)
createCheckpoint1
"Create a checkpoint recording the current state of the Context.
Even when all possible information is included in the State, the effect of calling this method
is still less complete than loadCheckpoint(). For example, it does not restore the internal
states of random number generators. On the other hand, it has the advantage of not being hardware
specific.
"""
self
.
setTime
(
state
.
_simTime
)
self
.
setPeriodicBoxVectors
(
state
.
_periodicBoxVectorsList
[
0
],
state
.
_periodicBoxVectorsList
[
1
],
state
.
_periodicBoxVectorsList
[
2
])
if
state
.
_coordList
is
not
None
:
self
.
setPositions
(
state
.
_coordList
)
if
state
.
_velList
is
not
None
:
self
.
setVelocities
(
state
.
_velList
)
if
state
.
_paramMap
is
not
None
:
for
param
in
state
.
_paramMap
:
self
.
setParameter
(
param
,
state
.
_paramMap
[
param
])
}
%
feature
(
"docstring"
)
createCheckpoint
"Create a checkpoint recording the current state of the Context.
This should be treated as an opaque block of binary data. See loadCheckpoint() for more details.
This should be treated as an opaque block of binary data. See loadCheckpoint() for more details.
Returns: a string containing the checkpoint data
Returns: a string containing the checkpoint data
"
"
std
::
string
createCheckpoint
1
()
{
std
::
string
createCheckpoint
()
{
std
::
stringstream
stream
(
std
::
ios_base
::
in
|
std
::
ios_base
::
out
|
std
::
ios_base
::
binary
)
;
std
::
stringstream
stream
(
std
::
ios_base
::
in
|
std
::
ios_base
::
out
|
std
::
ios_base
::
binary
)
;
self-
>
createCheckpoint
(
stream
)
;
self-
>
createCheckpoint
(
stream
)
;
return
stream
.
str
()
;
return
stream
.
str
()
;
...
...
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