Return a subautomaton such that their states are in the input states set.
Postcondition:
See also:
In [1]:
import vcsn
In [2]:
%%automaton aut
context = "lal_char(a), b"
0 -> 1 a
1 -> 0 a
0 -> 4 a
1 -> $
1 -> 2 a
$ -> 0
3 -> 4 a
4 -> 0 a
4 -> 5 a
To keep only states $0, 1, 2 , 3$:
In [3]:
aut.filter([0, 1, 2, 3])
Out[3]:
"Keeping" a non-existing state is not an error:
In [4]:
aut.filter([0, 1, 7])
Out[4]:
Calls to filter
can be filtered:
In [5]:
a1 = aut.filter([0, 1, 2, 3, 4]).filter([0, 1, 3, 5])
a1
Out[5]:
but it is less efficient than filtering on the intersection. This is on purpose: the outter automaton has a view on the filtered automaton.
In [6]:
a2 = aut.filter(list(set([0, 1, 2, 3, 4]) & set([0, 1, 3, 5])))
print(a1.info()['type'])
print(a2.info()['type'])
print(a1.is_isomorphic(a2))
We can filter a transposed automaton:
In [7]:
trans = aut.transpose()
trans
Out[7]:
In [8]:
trans.filter([0, 1, 2, 4])
Out[8]: