python: cleanup with autopep8

* tests/python/341.py, tests/python/alarm.py, tests/python/bdddict.py,
tests/python/bddnqueen.py, tests/python/bugdet.py,
tests/python/dualize.py, tests/python/except.py, tests/python/gen.py,
tests/python/genem.py, tests/python/implies.py,
tests/python/interdep.py, tests/python/ipnbdoctest.py,
tests/python/kripke.py, tests/python/ltl2tgba.py,
tests/python/ltlf.py, tests/python/ltlparse.py,
tests/python/ltlsimple.py, tests/python/relabel.py,
tests/python/rs_like.py, tests/python/sccsplit.py,
tests/python/semidet.py, tests/python/setacc.py,
tests/python/setxor.py, tests/python/split.py,
tests/python/streett_totgba.py, tests/python/stutter.py,
tests/python/sum.py, tests/python/toparity.py, tests/python/toweak.py,
tests/python/trival.py, python/spot/__init__.py, python/spot/aux.py,
python/spot/jupyter.py: Reformat with autopep8.

fixup! * spot/tl/simplify.cc: Fix typos in tracing code.
This commit is contained in:
Alexandre Duret-Lutz 2019-07-02 10:12:44 +02:00
parent 5b01ce32dd
commit 822fe77891
33 changed files with 444 additions and 356 deletions

View file

@ -21,68 +21,78 @@
import spot
import buddy
match_strings = [('is_buchi', 'is_co_buchi'),\
('is_generalized_buchi', 'is_generalized_co_buchi'),\
('is_all', 'is_none'),\
match_strings = [('is_buchi', 'is_co_buchi'),
('is_generalized_buchi', 'is_generalized_co_buchi'),
('is_all', 'is_none'),
('is_all', 'is_all'),
('is_buchi', 'is_all')]
# existential and universal are dual
# deterministic is self-dual
def dualtype(aut, dual):
if dual.acc().is_none(): return True
return (not spot.is_deterministic(aut) or spot.is_deterministic(dual))\
and (spot.is_universal(dual) or not aut.is_existential())\
and (dual.is_existential() or not spot.is_universal(aut))
if dual.acc().is_none():
return True
return (not spot.is_deterministic(aut) or spot.is_deterministic(dual))\
and (spot.is_universal(dual) or not aut.is_existential())\
and (dual.is_existential() or not spot.is_universal(aut))
def produce_phi(rg, n):
phi = []
while len(phi) < n:
phi.append(rg.next())
return phi
phi = []
while len(phi) < n:
phi.append(rg.next())
return phi
def produce_automaton(phi):
aut = []
for f in phi:
aut.append(spot.translate(f))
return aut
aut = []
for f in phi:
aut.append(spot.translate(f))
return aut
def test_aut(aut, d = None):
if d is None:
d = spot.dualize(aut)
aa = aut.acc()
da = d.acc()
complete = spot.is_complete(aut)
univ = aut.is_univ_dest(aut.get_init_state_number())
an = aut.num_states()
dn = d.num_states()
def test_aut(aut, d=None):
if d is None:
d = spot.dualize(aut)
aa = aut.acc()
da = d.acc()
if not dualtype(aut, d):
return (False, 'Incorrect transition mode resulting of dual')
for p in match_strings:
if ((getattr(aa, p[0])() and getattr(da, p[1])())\
or (getattr(aa, p[1])() and getattr(da, p[0])())):
return (True, '')
return (False, 'Incorrect acceptance type dual')
complete = spot.is_complete(aut)
univ = aut.is_univ_dest(aut.get_init_state_number())
an = aut.num_states()
dn = d.num_states()
if not dualtype(aut, d):
return (False, 'Incorrect transition mode resulting of dual')
for p in match_strings:
if ((getattr(aa, p[0])() and getattr(da, p[1])())
or (getattr(aa, p[1])() and getattr(da, p[0])())):
return (True, '')
return (False, 'Incorrect acceptance type dual')
# Tests that a (deterministic) automaton and its complement have complementary
# languages.
# FIXME This test could be extended to non-deterministic automata with a
# dealternization procedure.
def test_complement(aut):
assert aut.is_deterministic()
d = spot.dualize(aut)
s = spot.product_or(aut, d)
assert spot.dualize(s).is_empty()
assert aut.is_deterministic()
d = spot.dualize(aut)
s = spot.product_or(aut, d)
assert spot.dualize(s).is_empty()
def test_assert(a, d=None):
t = test_aut(a, d)
if not t[0]:
print (t[1])
print (a.to_str('hoa'))
print (spot.dualize(a).to_str('hoa'))
assert False
t = test_aut(a, d)
if not t[0]:
print (t[1])
print (a.to_str('hoa'))
print (spot.dualize(a).to_str('hoa'))
assert False
aut = spot.translate('a')
@ -591,8 +601,8 @@ spot.srand(0)
rg = spot.randltlgenerator(2, opts)
for a in produce_automaton(produce_phi(rg, 1000)):
test_assert(a)
test_assert(spot.dualize(a), spot.dualize(spot.dualize(a)))
test_assert(a)
test_assert(spot.dualize(a), spot.dualize(spot.dualize(a)))
aut = spot.automaton("""
HOA: v1
@ -606,4 +616,4 @@ State: 0
test_complement(aut)
for a in spot.automata('randaut -A \"random 0..6\" -H -D -n50 4|'):
test_complement(a)
test_complement(a)