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
6a50de8a
Commit
6a50de8a
authored
Oct 29, 2015
by
Robert McGibbon
Browse files
Fix force group 31
parent
596a4197
Changes
2
Show 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 @
6a50de8a
%
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
{
PyObject
*
_getStateAsLists
(
int
getPositions
,
int
getVelocities
,
...
...
@@ -5,7 +29,7 @@
int
getEnergy
,
int
getParameters
,
int
enforcePeriodic
,
in
t
groups
)
{
bitmask32
t
groups
)
{
State
state
;
PyThreadState
*
_savePythonThreadState
=
PyEval_SaveThread
()
;
int
types
=
0
;
...
...
@@ -36,15 +60,9 @@
enforcePeriodicBox
=
False
,
groups
=-
1
)
:
"""
getState(self,
getPositions = False,
getVelocities = False,
getForces = False,
getEnergy = False,
getParameters = False,
enforcePeriodicBox = False,
groups = -1)
-> State
getState(self, getPositions=False, getVelocities=False, getForces=False,
getEnergy=False, getParameters=False, enforcePeriodicBox=False,
groups=-1) -> State
Get a State object recording the current state information stored in this context.
...
...
wrappers/python/tests/TestForceGroups.py
View file @
6a50de8a
...
...
@@ -20,7 +20,7 @@ class TestForceGroups(unittest.TestCase):
self
.
context
=
context
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
):
groups
=
1
<<
i
|
1
<<
j
e_0
=
self
.
context
.
getState
(
getEnergy
=
True
,
groups
=
groups
).
getPotentialEnergy
().
_value
...
...
@@ -34,6 +34,12 @@ class TestForceGroups(unittest.TestCase):
# groups must be an int or set
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__'
:
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