python: implement twa_graph.__copy__

Fixes #470, suggested by Cambridge Yang.

* python/spot/__init__.py (twa_graph.__copy__): Call make_twa_graph.
* tests/python/twagraph.py: Test it.
* NEWS: Mention it.
This commit is contained in:
Alexandre Duret-Lutz 2021-07-08 09:33:57 +02:00
parent 0509263f82
commit 0cf2d285b6
3 changed files with 16 additions and 3 deletions

View file

@ -44,7 +44,7 @@ except ValueError as e:
aut.new_states(3)
aut.set_init_state(2)
assert aut.get_init_state_number() == 2
e = aut.set_univ_init_state([2, 1])
aut.set_univ_init_state([2, 1])
assert [2, 1] == list(aut.univ_dests(aut.get_init_state_number()))
try:
@ -67,6 +67,13 @@ cpy = spot.make_twa_graph(aut, spot.twa_prop_set(False, False, False,
assert cpy.prop_universal() != aut.prop_universal()
assert cpy.prop_universal() == spot.trival.maybe()
from copy import copy
cpy = copy(aut)
assert aut.to_str() == cpy.to_str()
cpy.set_init_state(1)
assert [2, 1] == list(aut.univ_dests(aut.get_init_state_number()))
assert cpy.get_init_state_number() == 1
try:
s = aut.state_acc_sets(0)
except RuntimeError as e: