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
5151d502
Commit
5151d502
authored
Oct 30, 2015
by
peastman
Browse files
Merge pull request #1226 from rmcgibbo/forcegroup-31
Fix force group 31
parents
596a4197
6a50de8a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
11 deletions
+35
-11
wrappers/python/src/swig_doxygen/swig_lib/python/extend.i
wrappers/python/src/swig_doxygen/swig_lib/python/extend.i
+28
-10
wrappers/python/tests/TestForceGroups.py
wrappers/python/tests/TestForceGroups.py
+7
-1
No files found.
wrappers/python/src/swig_doxygen/swig_lib/python/extend.i
View file @
5151d502
%
inline
%
{
typedef
int
bitmask32t
;
%
}
%
typemap
(
in
)
bitmask32t
%
{
$
1
=
0
;
#
if
PY_VERSION_HEX
>=
0x03000000
if
(
PyLong_Check
(
$
input
))
{
unsigned
long
u
=
PyLong_AsUnsignedLongMask
(
$
input
)
;
#
else
if
(
PyInt_Check
(
$
input
))
{
unsigned
long
u
=
PyInt_AsUnsignedLongMask
(
$
input
)
;
#
endif
// 64-bit Windows has 32-bit longs, but other platforms have
// 64-bit longs
$
1
=
u
&
0xffffffff
;
}
else
{
PyErr_SetString
(
PyExc_ValueError
,
"in method $symname, argument $argnum could not be converted to type $type"
)
;
SWIG_fail
;
}
%
}
%
extend
OpenMM
::
Context
{
%
extend
OpenMM
::
Context
{
PyObject
*
_getStateAsLists
(
int
getPositions
,
PyObject
*
_getStateAsLists
(
int
getPositions
,
int
getVelocities
,
int
getVelocities
,
...
@@ -5,7 +29,7 @@
...
@@ -5,7 +29,7 @@
int
getEnergy
,
int
getEnergy
,
int
getParameters
,
int
getParameters
,
int
enforcePeriodic
,
int
enforcePeriodic
,
in
t
groups
)
{
bitmask32
t
groups
)
{
State
state
;
State
state
;
PyThreadState
*
_savePythonThreadState
=
PyEval_SaveThread
()
;
PyThreadState
*
_savePythonThreadState
=
PyEval_SaveThread
()
;
int
types
=
0
;
int
types
=
0
;
...
@@ -36,15 +60,9 @@
...
@@ -36,15 +60,9 @@
enforcePeriodicBox
=
False
,
enforcePeriodicBox
=
False
,
groups
=-
1
)
:
groups
=-
1
)
:
"""
"""
getState(self,
getState(self, getPositions=False, getVelocities=False, getForces=False,
getPositions = False,
getEnergy=False, getParameters=False, enforcePeriodicBox=False,
getVelocities = False,
groups=-1) -> State
getForces = False,
getEnergy = False,
getParameters = False,
enforcePeriodicBox = False,
groups = -1)
-> State
Get a State object recording the current state information stored in this context.
Get a State object recording the current state information stored in this context.
...
...
wrappers/python/tests/TestForceGroups.py
View file @
5151d502
...
@@ -20,7 +20,7 @@ class TestForceGroups(unittest.TestCase):
...
@@ -20,7 +20,7 @@ class TestForceGroups(unittest.TestCase):
self
.
context
=
context
self
.
context
=
context
def
test1
(
self
):
def
test1
(
self
):
n
=
3
1
# Should be 32, but github issue #1198
n
=
3
2
for
(
i
,
j
)
in
itertools
.
combinations
(
range
(
n
),
2
):
for
(
i
,
j
)
in
itertools
.
combinations
(
range
(
n
),
2
):
groups
=
1
<<
i
|
1
<<
j
groups
=
1
<<
i
|
1
<<
j
e_0
=
self
.
context
.
getState
(
getEnergy
=
True
,
groups
=
groups
).
getPotentialEnergy
().
_value
e_0
=
self
.
context
.
getState
(
getEnergy
=
True
,
groups
=
groups
).
getPotentialEnergy
().
_value
...
@@ -34,6 +34,12 @@ class TestForceGroups(unittest.TestCase):
...
@@ -34,6 +34,12 @@ class TestForceGroups(unittest.TestCase):
# groups must be an int or set
# groups must be an int or set
self
.
context
.
getState
(
getEnergy
=
True
,
groups
=
(
1
,
2
))
self
.
context
.
getState
(
getEnergy
=
True
,
groups
=
(
1
,
2
))
def
test3
(
self
):
e_0
=
self
.
context
.
getState
(
getEnergy
=
True
,
groups
=-
1
).
getPotentialEnergy
().
_value
e_ref
=
sum
(
range
(
32
))
self
.
assertEqual
(
e_0
,
e_ref
)
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