Skip to content

Commit

Permalink
Ensure time remains positive following a timeshift
Browse files Browse the repository at this point in the history
  • Loading branch information
Gaudeval committed Aug 12, 2020
1 parent 4f13813 commit f3b84ef
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion mtl/evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ def eval_mtl_next(phi, dt):
f = eval_mtl(phi.arg, dt)

def _eval(x):
return (f(x) << dt).retag({phi.arg: phi})
v = (f(x) << dt)
return v[max(v.start, 0):].retag({phi.arg: phi})

return _eval

Expand Down
9 changes: 9 additions & 0 deletions mtl/test_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,12 @@ def test_eval_regression_smoke1():
}
f2 = mtl.parse('(a U[0,3] b)')
f2(d2, quantitative=False)


def test_eval_regression_next_neg():
"""From issue #219"""
d = {"a": [(0, False), (1, True)]}
f = mtl.parse("(a & (X (~a)))")
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

0 comments on commit f3b84ef

Please sign in to comment.