From 9e30ddb060591a29dd2ca5bfade10b7d94bbd304 Mon Sep 17 00:00:00 2001 From: Marcell Vazquez-Chanlatte Date: Fri, 4 Nov 2016 15:59:32 -0700 Subject: [PATCH] testing boolean evaluation --- stl/boolean_eval.py | 2 +- stl/test_boolean_eval.py | 9 ++++++--- stl/test_parser.py | 7 +++++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/stl/boolean_eval.py b/stl/boolean_eval.py index f1f0772..4f9caf8 100644 --- a/stl/boolean_eval.py +++ b/stl/boolean_eval.py @@ -55,7 +55,7 @@ op_lookup = { @pointwise_sat.register(stl.AtomicPred) def _(stl): - return lambda x, t: x[term.id][t] + return lambda x, t: x[stl.id][t] @pointwise_sat.register(stl.LinEq) diff --git a/stl/test_boolean_eval.py b/stl/test_boolean_eval.py index de5cbbe..1b1cb91 100644 --- a/stl/test_boolean_eval.py +++ b/stl/test_boolean_eval.py @@ -11,11 +11,14 @@ ex3 = ("F[1, 0](2*A > 3)", False) ex4 = ("G[1, 0](2*A > 3)", True) ex5 = ("(A < 0)", False) ex6 = ("G[0, 0.1](A < 0)", False) -x = pd.DataFrame([[1,2], [1,4], [4,2]], index=[0,0.1,0.2], - columns=["A", "B"]) +ex7 = ("G[0, 0.1](C)", True) +ex7 = ("G[0, 0.2](C)", False) +ex7 = ("(F[0, 0.2](C)) and (F[0, 1](2*A > 3))", True) +x = pd.DataFrame([[1,2, True], [1,4, True], [4,2, False]], index=[0,0.1,0.2], + columns=["A", "B", "C"]) class TestSTLRobustness(unittest.TestCase): - @params(ex1, ex2, ex3, ex4, ex5, ex6) + @params(ex1, ex2, ex3, ex4, ex5, ex6, ex7) def test_stl(self, phi_str, r): phi = stl.parse(phi_str) stl_eval = stl.boolean_eval.pointwise_sat(phi) diff --git a/stl/test_parser.py b/stl/test_parser.py index fbb5349..480e4d3 100644 --- a/stl/test_parser.py +++ b/stl/test_parser.py @@ -15,6 +15,8 @@ ex1_ = ('x1 > a?', stl.LinEq( Symbol("a?") )) +ex1__ = ('x1', stl.AtomicPred('x1')) + i1 = stl.Interval(0., 1.) i1_ = stl.Interval(0., Symbol("b?")) i2 = stl.Interval(2., 3.) @@ -23,9 +25,10 @@ ex3 = ('□[2,3]◇[0,1](x1 > 2)', stl.G(i2, ex2[1])) ex4 = ('(x1 > 2) or ((x1 > 2) or (x1 > 2))', stl.Or((ex1[1], ex1[1], ex1[1]))) ex5 = ('G[0, b?](x1 > a?)', - stl.G(i1_, ex1_)) + stl.G(i1_, ex1_[1])) +ex6 = ('◇[0,1](x1)', stl.F(i1, ex1__[1])) class TestSTLParser(unittest.TestCase): - @params(ex1, ex2, ex3, ex4) + @params(ex1, ex2, ex3, ex4, ex5, ex6) def test_stl(self, phi_str, phi): self.assertEqual(stl.parse(phi_str), phi)