Skip to content

Commit

Permalink
Fix until output not valued at signal start
Browse files Browse the repository at this point in the history
  • Loading branch information
Gaudeval committed Jan 6, 2021
1 parent 0195ab2 commit 2cff512
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
6 changes: 6 additions & 0 deletions mtl/evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ def interp(sig, t, tag=None):
return sig[key][tag]


def interp_all(sig, t, end=OO):
v = fn.map(lambda u: signal([(t, interp(sig, t, u))], t, end, u), sig.tags)
return reduce(op.__or__, v)


def dense_compose(sig1, sig2, init=None):
sig12 = sig1 | sig2
tags = sig12.tags
Expand Down Expand Up @@ -110,6 +115,7 @@ def eval_mtl_until(phi, dt):

def _eval(x):
sig = dense_compose(f1(x), f2(x), init=-OO)
sig = sig | interp_all(sig, x.start, OO) # Force valuation at start
data = apply_weak_until(phi.arg1, phi.arg2, sig)
return signal(data, x.start, OO, tag=phi)

Expand Down
10 changes: 10 additions & 0 deletions mtl/test_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,13 @@ def test_eval_regression_next_neg():
v = f(d, quantitative=False, dt=1, time=None)
assert not f(d, quantitative=False, dt=1)
assert min(t for t, _ in v) >= 0


def test_eval_regression_until_start():
"""From issue #221"""
x = {
"ap1": [(0, True), (0.1, True), (0.2, False)],
}

phi = (mtl.parse("(X TRUE W X TRUE)"))
phi(x, 0, quantitative=False)

0 comments on commit 2cff512

Please sign in to comment.