fix bug in robustness calculation + move synth for it's on module
This commit is contained in:
parent
9b42d9bb57
commit
da669f088d
4 changed files with 58 additions and 52 deletions
|
|
@ -1,5 +1,6 @@
|
|||
import stl
|
||||
import stl.robustness
|
||||
import stl.synth
|
||||
import pandas as pd
|
||||
from nose2.tools import params
|
||||
import unittest
|
||||
|
|
@ -13,9 +14,10 @@ ex2 = ("F[0, b?](A > a?)", ("a?", "b?"), {"a?": (0, 10), "b?": (0, 5)},
|
|||
ex3 = ("F[0, b?](A < 0)", ("b?",), {"b?": (0, 5)},
|
||||
{"b?": True}, {"b?": 5})
|
||||
ex4 = ("G[0, b?](A < 0)", ("b?",), {"b?": (0.1, 5)},
|
||||
{"b?": True}, {"b?": 0.1})
|
||||
{"b?": False}, {"b?": 0.1})
|
||||
ex5 = ("F[0, b?](A > 0)", ("b?",), {"b?": (0.1, 5)},
|
||||
{"b?": True}, {"b?": 0.1})
|
||||
|
||||
x = pd.DataFrame([[1,2], [1,4], [4,2]], index=[0,0.1,0.2],
|
||||
columns=["A", "B"])
|
||||
|
||||
|
|
@ -24,14 +26,14 @@ class TestSTLRobustness(unittest.TestCase):
|
|||
@params(ex1, ex2, ex3, ex4, ex5)
|
||||
def test_lex_synth(self, phi_str, order, ranges, polarity, val):
|
||||
phi = stl.parse(phi_str)
|
||||
val2 = stl.robustness.lex_param_project(
|
||||
val2 = stl.synth.lex_param_project(
|
||||
phi, x, order=order, ranges=ranges, polarity=polarity)
|
||||
|
||||
phi = stl.robustness.set_params(phi, val2)
|
||||
phi2 = stl.robustness.set_params(phi, val)
|
||||
phi2 = stl.utils.set_params(phi, val2)
|
||||
phi3 = stl.utils.set_params(phi, val)
|
||||
|
||||
stl_eval = stl.robustness.pointwise_robustness(phi)
|
||||
stl_eval2 = stl.robustness.pointwise_robustness(phi2)
|
||||
stl_eval = stl.robustness.pointwise_robustness(phi2)
|
||||
stl_eval2 = stl.robustness.pointwise_robustness(phi3)
|
||||
|
||||
# check that the robustnesses are almost the same
|
||||
self.assertAlmostEqual(stl_eval(x, 0), stl_eval2(x, 0), delta=0.01)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue