Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
FiniteStateMachine: add failing doctests: non-hashable colors
Browse files Browse the repository at this point in the history
The following behaviour is undesired (docstrings says that
colors are tuples of the colors of the constituent states,
but this is not the case and leads to problems in
Automaton.determinisation):

    sage: A = Automaton([[0, 0, 0]], initial_states=[0])
    sage: B = A.product_FiniteStateMachine(A,
    ....:                                  lambda t1, t2: (0, None))
    sage: B.states()[0].color
    [None, None]
    sage: B.determinisation()
    Traceback (most recent call last):
    ...
    TypeError: unhashable type: 'list'

    sage: A = Automaton([[0, 0, 0]], initial_states=[0])
    sage: B = A.composition(A, algorithm='explorative')
    sage: B.states()[0].color
    [None, None]
    sage: B.determinisation()
    Traceback (most recent call last):
    ...
    TypeError: unhashable type: 'list'

Inserted doctests documenting this undesired behaviour.
  • Loading branch information
cheuberg committed Apr 5, 2014
1 parent 2031f53 commit 2d43fdd
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/sage/combinat/finite_state_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -3625,6 +3625,21 @@ def product_FiniteStateMachine(self, other, function,
....: only_accessible_components=False)
sage: H.states()
[(0, 0), (1, 0), (0, 1), (1, 1)]
TESTS:
Check that colors are correctly dealt with. In particular, the
new colors have to be hashable such that
:meth:`Automaton.determinisation` does not fail::
sage: A = Automaton([[0, 0, 0]], initial_states=[0])
sage: B = A.product_FiniteStateMachine(A,
....: lambda t1, t2: (0, None))
sage: B.states()[0].color
(None, None)
sage: B.determinisation()
Automaton with 1 states
"""
result = self.empty_copy()
if new_input_alphabet is not None:
Expand Down Expand Up @@ -3902,6 +3917,17 @@ def _composition_explorative_(self, other):
Transition from ('B', 1) to ('B', 1): 0|0,
Transition from ('B', 1) to ('B', 2): 1|0]
Check that colors are correctly dealt with. In particular, the
new colors have to be hashable such that
:meth:`Automaton.determinisation` does not fail::
sage: A = Automaton([[0, 0, 0]], initial_states=[0])
sage: B = A.composition(A, algorithm='explorative')
sage: B.states()[0].color
(None, None)
sage: B.determinisation()
Automaton with 1 states
TODO:
The explorative algorithm should be re-implemented using the
Expand Down

0 comments on commit 2d43fdd

Please sign in to comment.