fixed bug in next operator and global operator
This commit is contained in:
parent
cdc18225fd
commit
c495216626
3 changed files with 29 additions and 13 deletions
|
|
@ -116,9 +116,16 @@ def eval_stl_g(phi, dt):
|
||||||
)])
|
)])
|
||||||
for (start, val), (end, val2) in intervals:
|
for (start, val), (end, val2) in intervals:
|
||||||
start2, end2 = start - b, end + a
|
start2, end2 = start - b, end + a
|
||||||
if end2 > start2 and start2:
|
if end2 > start2:
|
||||||
yield (start2, val)
|
yield (start2, val)
|
||||||
|
|
||||||
|
if b == float('inf'):
|
||||||
|
def _eval(x):
|
||||||
|
y = f(x)
|
||||||
|
val = len(y.slice(a, b)) == 1 and y[a]
|
||||||
|
return traces.TimeSeries(
|
||||||
|
[(y.domain.start(), val)], domain=y.domain)
|
||||||
|
else:
|
||||||
def _eval(x):
|
def _eval(x):
|
||||||
y = f(x)
|
y = f(x)
|
||||||
if len(y) <= 1:
|
if len(y) <= 1:
|
||||||
|
|
@ -150,7 +157,8 @@ def eval_stl_next(phi, dt):
|
||||||
|
|
||||||
def _eval(x):
|
def _eval(x):
|
||||||
y = f(x)
|
y = f(x)
|
||||||
out = traces.TimeSeries(((t + dt, v) for t, v in y), domain=y.domain)
|
out = traces.TimeSeries(((t - dt, v) for t, v in y))
|
||||||
|
out = out.slice(y.domain.start(), y.domain.end())
|
||||||
out.compact()
|
out.compact()
|
||||||
|
|
||||||
return out
|
return out
|
||||||
|
|
|
||||||
|
|
@ -18,5 +18,5 @@ GRAMMAR = {
|
||||||
SignalTemporalLogicStrategy = st.builds(lambda term: stl.parse(''.join(term)),
|
SignalTemporalLogicStrategy = st.builds(lambda term: stl.parse(''.join(term)),
|
||||||
ContextFreeGrammarStrategy(
|
ContextFreeGrammarStrategy(
|
||||||
GRAMMAR,
|
GRAMMAR,
|
||||||
max_length=15,
|
max_length=14,
|
||||||
start='phi'))
|
start='phi'))
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import hypothesis.strategies as st
|
import hypothesis.strategies as st
|
||||||
import traces
|
import traces
|
||||||
from hypothesis import given
|
from hypothesis import given, settings, Verbosity, Phase
|
||||||
from pytest import raises
|
from pytest import raises
|
||||||
|
|
||||||
import stl
|
import stl
|
||||||
|
|
@ -81,6 +81,11 @@ def test_eval_smoke_tests(phi):
|
||||||
|
|
||||||
|
|
||||||
@given(SignalTemporalLogicStrategy)
|
@given(SignalTemporalLogicStrategy)
|
||||||
|
@settings(
|
||||||
|
max_shrinks=0,
|
||||||
|
verbosity=Verbosity.verbose,
|
||||||
|
perform_health_check=False,
|
||||||
|
phases=[Phase.generate])
|
||||||
def test_temporal_identities(phi):
|
def test_temporal_identities(phi):
|
||||||
stl_eval = stl.boolean_eval.pointwise_sat(phi)
|
stl_eval = stl.boolean_eval.pointwise_sat(phi)
|
||||||
stl_eval2 = stl.boolean_eval.pointwise_sat(~phi)
|
stl_eval2 = stl.boolean_eval.pointwise_sat(~phi)
|
||||||
|
|
@ -93,10 +98,13 @@ def test_temporal_identities(phi):
|
||||||
assert not stl_eval5(x, 0)
|
assert not stl_eval5(x, 0)
|
||||||
stl_eval6 = stl.boolean_eval.pointwise_sat(phi | ~phi)
|
stl_eval6 = stl.boolean_eval.pointwise_sat(phi | ~phi)
|
||||||
assert stl_eval6(x, 0)
|
assert stl_eval6(x, 0)
|
||||||
|
stl_eval7 = stl.boolean_eval.pointwise_sat(stl.ast.Until(stl.TOP, phi))
|
||||||
|
stl_eval8 = stl.boolean_eval.pointwise_sat(stl.env(phi))
|
||||||
|
assert stl_eval7(x, 0) == stl_eval8(x, 0)
|
||||||
|
|
||||||
|
|
||||||
@given(st.just(stl.BOT))
|
@given(st.just(stl.BOT))
|
||||||
def test_temporal_identities2(phi):
|
def test_fastboolean_equiv(phi):
|
||||||
stl_eval = stl.fastboolean_eval.pointwise_sat(stl.alw(phi, lo=0, hi=4))
|
stl_eval = stl.fastboolean_eval.pointwise_sat(stl.alw(phi, lo=0, hi=4))
|
||||||
stl_eval2 = stl.fastboolean_eval.pointwise_sat(~stl.env(~phi, lo=0, hi=4))
|
stl_eval2 = stl.fastboolean_eval.pointwise_sat(~stl.env(~phi, lo=0, hi=4))
|
||||||
assert stl_eval2(x, 0) == stl_eval(x, 0)
|
assert stl_eval2(x, 0) == stl_eval(x, 0)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue