本文整理汇总了Python中models.Record.setColumnValue方法的典型用法代码示例。如果您正苦于以下问题:Python Record.setColumnValue方法的具体用法?Python Record.setColumnValue怎么用?Python Record.setColumnValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Record
的用法示例。
在下文中一共展示了Record.setColumnValue方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testExpressionParsing
# 需要导入模块: from models import Record [as 别名]
# 或者: from models.Record import setColumnValue [as 别名]
def testExpressionParsing(self):
from models import Record
r = Record()
x = 5
y = -2
z = 3.5
r.setColumnValue("x", x)
r.setColumnValue("y", y)
r.setColumnValue("z", z)
volley = [
["1 + 1", (1 + 1) ],
["1 + 1 + 5", (1 + 1 + 5) ],
["2 * 8 + 3", (2*8) + 3 ],
["4 + 5 * 2", 4 + (5*2)],
["2^3", (pow(2,3)) ],
["(8/2)*3 + 9", ((8/2)*3 + 9) ],
["[x]^2", (pow(x,2))],
["SQRT([x]^2 + [y]^2)", ( math.sqrt(pow(x,2)+pow(y,2)) )],
["5 > 2", True],
["5 > 6", False],
["(3*5) < 20", True],
["[x] > 100", False],
["(3*5) < 20 AND [x] > 100", False],
["(3*5) < 20 AND [x] > 0 AND [x] > 1", True],
["1==1 OR 1==3 AND 2==0", True],
["(1==1 OR 1==3) AND 2==2", True],
["(1==2 AND 1==3) OR 2==2", True],
["(1==1 OR 1==1) AND 1==0", False],
["1==1 OR 1==1 AND 1==0", True], # And first
["1==1 OR (1==1 AND 1==0)", True],
["1 == 2 OR [x] > 100 OR [x] > 1", True],
["1==2 OR 1==1 OR 1==4 OR 1==5", True],
["SQRT([x]^2 + [y]^2)", ( math.sqrt(pow(x,2)+pow(y,2)) )],
["SQRT([x]^2 + [y]^2 + 8^2)", ( math.sqrt(pow(x,2)+pow(y,2)+pow(8,2))) ],
["SQRT([x]^2 + [y]^2 + [z]^2)", ( math.sqrt(pow(x,2)+pow(y,2)+pow(z,2))) ]
]
for v in volley:
expr = v[0]
target = v[1]
tick = datetime.now()
ep = ExpressionParser(expr, verbose=True)
result = ep.run(r)
tock = datetime.now()
diff = tock - tick
ms = diff.microseconds/1000
logmessage = "%s took %d ms" % (expr, ms)
if ms > 100:
logmessage += " <<<<<<<<<<<<<<<<<<<<<<<<<<< SLOW OP!"
print logmessage
self.assertEqual(result, target)