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,18 +116,25 @@ def eval_stl_g(phi, dt):
|
|||
)])
|
||||
for (start, val), (end, val2) in intervals:
|
||||
start2, end2 = start - b, end + a
|
||||
if end2 > start2 and start2:
|
||||
if end2 > start2:
|
||||
yield (start2, val)
|
||||
|
||||
def _eval(x):
|
||||
y = f(x)
|
||||
if len(y) <= 1:
|
||||
return y
|
||||
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):
|
||||
y = f(x)
|
||||
if len(y) <= 1:
|
||||
return y
|
||||
|
||||
out = traces.TimeSeries(process_intervals(y)).slice(
|
||||
y.domain.start(), y.domain.end())
|
||||
out.compact()
|
||||
return out
|
||||
out = traces.TimeSeries(process_intervals(y)).slice(
|
||||
y.domain.start(), y.domain.end())
|
||||
out.compact()
|
||||
return out
|
||||
|
||||
return _eval
|
||||
|
||||
|
|
@ -150,7 +157,8 @@ def eval_stl_next(phi, dt):
|
|||
|
||||
def _eval(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()
|
||||
|
||||
return out
|
||||
|
|
|
|||
|
|
@ -18,5 +18,5 @@ GRAMMAR = {
|
|||
SignalTemporalLogicStrategy = st.builds(lambda term: stl.parse(''.join(term)),
|
||||
ContextFreeGrammarStrategy(
|
||||
GRAMMAR,
|
||||
max_length=15,
|
||||
max_length=14,
|
||||
start='phi'))
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import hypothesis.strategies as st
|
||||
import traces
|
||||
from hypothesis import given
|
||||
from hypothesis import given, settings, Verbosity, Phase
|
||||
from pytest import raises
|
||||
|
||||
import stl
|
||||
|
|
@ -81,6 +81,11 @@ def test_eval_smoke_tests(phi):
|
|||
|
||||
|
||||
@given(SignalTemporalLogicStrategy)
|
||||
@settings(
|
||||
max_shrinks=0,
|
||||
verbosity=Verbosity.verbose,
|
||||
perform_health_check=False,
|
||||
phases=[Phase.generate])
|
||||
def test_temporal_identities(phi):
|
||||
stl_eval = 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)
|
||||
stl_eval6 = stl.boolean_eval.pointwise_sat(phi | ~phi)
|
||||
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))
|
||||
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_eval2 = stl.fastboolean_eval.pointwise_sat(~stl.env(~phi, lo=0, hi=4))
|
||||
assert stl_eval2(x, 0) == stl_eval(x, 0)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue