Skip to content

Commit f1e1274

Browse files
committed
Changed unit stripping to work with OpenMM 7.0
1 parent 6e362f6 commit f1e1274

File tree

1 file changed

+3
-21
lines changed

1 file changed

+3
-21
lines changed

python/exampleplugin.i

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
%module exampleplugin
22

3-
%import(module="simtk.openmm") "OpenMMSwigHeaders.i"
4-
3+
%import(module="simtk.openmm") "swig/OpenMMSwigHeaders.i"
4+
%include "swig/typemaps.i"
55

66
/*
77
* The following lines are needed to handle std::vector.
@@ -24,35 +24,18 @@ namespace std {
2424
#include "openmm/RPMDMonteCarloBarostat.h"
2525
%}
2626

27-
28-
/*
29-
* The code below strips all units before the wrapper
30-
* functions are called. This code also converts numpy
31-
* arrays to lists.
32-
*/
33-
3427
%pythoncode %{
3528
import simtk.openmm as mm
3629
import simtk.unit as unit
3730
%}
3831

39-
40-
/* strip the units off of all input arguments */
41-
%pythonprepend %{
42-
try:
43-
args=mm.stripUnits(args)
44-
except UnboundLocalError:
45-
pass
46-
%}
47-
48-
4932
/*
5033
* Add units to function outputs.
5134
*/
5235
%pythonappend ExamplePlugin::ExampleForce::getBondParameters(int index, int& particle1, int& particle2,
5336
double& length, double& k) const %{
5437
val[2] = unit.Quantity(val[2], unit.nanometer)
55-
val[3] = unit.Quantity(val[3], unit.kilojoule_per_mole / (unit.nanometer * unit.nanometer))
38+
val[3] = unit.Quantity(val[3], unit.kilojoule_per_mole/unit.nanometer**4)
5639
%}
5740

5841

@@ -86,4 +69,3 @@ public:
8669
};
8770

8871
}
89-

0 commit comments

Comments
 (0)