support discretizing top and bot

This commit is contained in:
Marcell Vazquez-Chanlatte 2017-11-27 13:10:56 -08:00
parent b3bba24336
commit 38b8c1838f
2 changed files with 13 additions and 1 deletions

View file

@ -94,6 +94,18 @@ def test_discretize():
assert phi2 == stl.parse( assert phi2 == stl.parse(
'(~((X(A)) (X(X(A))))) ∧ (~((X(X(A))) (X(X(X(A))))))') '(~((X(A)) (X(X(A))))) ∧ (~((X(X(A))) (X(X(X(A))))))')
phi = stl.TOP
assert stl.utils.is_discretizable(phi, dt)
phi2 = stl.utils.discretize(phi, dt)
phi3 = stl.utils.discretize(phi2, dt)
assert phi2 == phi3
phi = stl.BOT
assert stl.utils.is_discretizable(phi, dt)
phi2 = stl.utils.discretize(phi, dt)
phi3 = stl.utils.discretize(phi2, dt)
assert phi2 == phi3
def test_scope(): def test_scope():
dt = 0.3 dt = 0.3

View file

@ -128,7 +128,7 @@ def discretize(phi, dt, distribute=False):
def _discretize(phi, dt): def _discretize(phi, dt):
if isinstance(phi, (LinEq, AtomicPred)): if isinstance(phi, (LinEq, AtomicPred, _Top, _Bot)):
return phi return phi
children = tuple(_discretize(arg, dt) for arg in phi.children) children = tuple(_discretize(arg, dt) for arg in phi.children)