"wrappers/vscode:/vscode.git/clone" did not exist on "49cbc791ee9bbc41f1fa516e5bf276300b6a28f2"
Commit 1644cc45 authored by Jason Swails's avatar Jason Swails
Browse files

Try to add tests for AmoebaOutOfPlaneBendForce. The units added to the

cubic/quartic/pentic/etc. terms are NOT working for some reason.
parent 48437a22
......@@ -10,6 +10,7 @@ import getopt
import re
import xml.etree.ElementTree as etree
from distutils.version import LooseVersion
import copy
try:
from html.parser import HTMLParser
......@@ -20,7 +21,6 @@ except ImportError:
INDENT = " "
docTags = {'emphasis':'i', 'bold':'b', 'itemizedlist':'ul', 'listitem':'li', 'preformatted':'pre', 'computeroutput':'tt', 'subscript':'sub'}
def striphtmltags(s):
"""Strip a couple html tags used inside docstrings in the C++ source
to produce something more easily read as plain text.
......@@ -477,10 +477,11 @@ class SwigInputBuilder:
valueUnits=[None, ()]
index=0
if valueUnits[0]:
if valueUnits[0] is not None:
sys.stdout.write("%s.%s() returns %s\n" %
(shortClassName, methName, valueUnits[0]))
if len(valueUnits[1])>0:
print('IT IS GREATER THAN 1')
addText = "%s%sval[%d]=unit.Quantity(val[%d], %s)\n" \
% (addText, INDENT,
index, index,
......
......@@ -268,10 +268,10 @@ UNITS = {
("AmoebaMultipoleForce", "getSystemMultipoleMoments") : ( None, ()),
("AmoebaOutOfPlaneBendForce", "getNumOutOfPlaneBends") : ( None, ()),
("AmoebaOutOfPlaneBendForce", "getAmoebaGlobalOutOfPlaneBendCubic") : ( None,()),
("AmoebaOutOfPlaneBendForce", "getAmoebaGlobalOutOfPlaneBendQuartic") : ( None,()),
("AmoebaOutOfPlaneBendForce", "getAmoebaGlobalOutOfPlaneBendPentic") : ( None,()),
("AmoebaOutOfPlaneBendForce", "getAmoebaGlobalOutOfPlaneBendSextic") : ( None,()),
("AmoebaOutOfPlaneBendForce", "getAmoebaGlobalOutOfPlaneBendCubic") : ( '1/unit.radian',()),
("AmoebaOutOfPlaneBendForce", "getAmoebaGlobalOutOfPlaneBendQuartic") : ( '1/unit.radian**2',()),
("AmoebaOutOfPlaneBendForce", "getAmoebaGlobalOutOfPlaneBendPentic") : ( '1/unit.radian**3',()),
("AmoebaOutOfPlaneBendForce", "getAmoebaGlobalOutOfPlaneBendSextic") : ( '1/unit.radian**4',()),
("AmoebaOutOfPlaneBendForce", "getOutOfPlaneBendParameters") : ( None, (None, None, None, None, 'unit.kilojoule_per_mole')),
("AmoebaPiTorsionForce", "getNumPiTorsions") : ( None, ()),
......
......@@ -681,5 +681,46 @@ class TestAPIUnits(unittest.TestCase):
self.assertEqual(tk, 1.0*kilocalorie_per_mole/radians**2)
self.assertIs(tk.unit, kilojoules_per_mole/radians**2)
def testAmoebaOutOfPlaneBendForce(self):
""" Tests the AmoebaOutOfPlaneBendForce API features """
force = AmoebaOutOfPlaneBendForce()
force.setAmoebaGlobalOutOfPlaneBendCubic(1.0)
self.assertEqual(force.getAmoebaGlobalOutOfPlaneBendCubic(), 1/radian)
self.assertEqual(str(force.getAmoebaGlobalOutOfPlaneBendCubic().unit), '/radian')
force.setAmoebaGlobalOutOfPlaneBendQuartic(1.0/degrees**2)
self.assertAlmostEqualUnit(force.getAmoebaGlobalOutOfPlaneBendQuartic(), 1/degrees**2)
self.assertEqual(str(force.getAmoebaGlobalOutOfPlaneBendQuartic().unit), '/(radian**2)')
force.setAmoebaGlobalOutOfPlaneBendPentic(1.0/radians**3)
self.assertEqual(force.getAmoebaGlobalOutOfPlaneBendPentic(), 1/radian**3)
self.assertEqual(str(force.getAmoebaGlobalOutOfPlaneBendPentic().unit), '/(radian**3)')
force.setAmoebaGlobalOutOfPlaneBendSextic(1.0/radians**4)
self.assertEqual(force.getAmoebaGlobalOutOfPlaneBendSextic(), 1/radian**4)
self.assertEqual(str(force.getAmoebaGlobalOutOfPlaneBendSextic().unit), '/(radian**4)')
force.addOutOfPlaneBend(0, 1, 2, 3, 1.0)
force.addOutOfPlaneBend(1, 2, 3, 4, 1.0*kilocalories_per_mole/radians**2)
self.assertEqual(force.getNumOutOfPlaneBends(), 2)
i, j, k, l, tk = force.getOutOfPlaneBendParameters(0)
self.assertEqual(i, 0)
self.assertEqual(j, 1)
self.assertEqual(k, 2)
self.assertEqual(l, 3)
self.assertEqual(tk, 1.0*kilojoules_per_mole)
self.assertIs(tk.unit, kilojoules_per_mole)
i, j, k, l, tk = force.getOutOfPlaneBendParameters(1)
self.assertEqual(i, 1)
self.assertEqual(j, 2)
self.assertEqual(k, 3)
self.assertEqual(l, 4)
self.assertEqual(tk, 1.0*kilocalorie_per_mole)
self.assertIs(tk.unit, kilojoules_per_mole)
if __name__ == '__main__':
unittest.main()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment