Opened 8 years ago
Closed 8 years ago
#16588 closed defect (fixed)
finite_state_machine.FSMState: New method fully_equal
Reported by:  cheuberg  Owned by:  

Priority:  minor  Milestone:  sage6.3 
Component:  finite state machines  Keywords:  finite_state_machine 
Cc:  skropf, dkrenn  Merged in:  
Authors:  Clemens Heuberger, Daniel Krenn  Reviewers:  Daniel Krenn, Clemens Heuberger 
Report Upstream:  N/A  Work issues:  
Branch:  0f3a40e (Commits, GitHub, GitLab)  Commit:  0f3a40eec3031f7175a4502591e8fedb04e99ee2 
Dependencies:  #16674  Stopgaps: 
Description
finite_state_machine.FSMState.__eq__
only compares labels of states, but not their other attributes such as is_initial
, is_final
, final_word_out
, word_out
, color
.
The reason is that states have to be hashable and that their hash only depends on the label  therefore, states with the same labels have to be equal.
This is no problem as long as states of the same finite state machine are compared. When comparing two finite state machines, this distinction matters.
Therefore, a new method FSMState.fully_equal
is introduced and used in FiniteStateMachine.__eq__
.
Change History (8)
comment:1 Changed 8 years ago by
 Status changed from new to needs_review
comment:2 Changed 8 years ago by
 Dependencies set to #16674
comment:3 Changed 8 years ago by
 Branch changed from u/cheuberg/fsm/states_equality to u/dkrenn/fsm/states_equality
comment:4 Changed 8 years ago by
 Commit changed from f5b24c3d638ec739511a19c7c9b5513968e652bd to 0f4cd95d215f9368d0ea9ecea8cf9fb87ee77449
 Reviewers set to Daniel Krenn
comment:5 Changed 8 years ago by
 Branch changed from u/dkrenn/fsm/states_equality to u/cheuberg/fsm/states_equality
comment:6 Changed 8 years ago by
 Commit changed from 0f4cd95d215f9368d0ea9ecea8cf9fb87ee77449 to 0f3a40eec3031f7175a4502591e8fedb04e99ee2
Branch pushed to git repo; I updated commit sha1. New commits:
dc5e17e  Minor correction in docstring (``...``)

77f3804  Minor rewording in docstring

063fb45  Merge remotetracking branch 'aau/fsm/processrefusenondeterministic' (#16539) into t/16675/fsm/check_equal

1d730fe  Merge branch 'u/cheuberg/fsm/check_equal' of trac.sagemath.org:sage into t/16674/fsm/is_monochromatic

0f3a40e  Merge branch 'u/cheuberg/fsm/is_monochromatic' of trac.sagemath.org:sage into fsm/states_equality

comment:7 Changed 8 years ago by
 Reviewers changed from Daniel Krenn to Daniel Krenn, Clemens Heuberger
 Status changed from needs_review to positive_review
Crossreviewed the changes. Added minor correction to docstring. Merged current version of dependency #16674 in order to avoid failing of trac's automerge.
comment:8 Changed 8 years ago by
 Branch changed from u/cheuberg/fsm/states_equality to 0f3a40eec3031f7175a4502591e8fedb04e99ee2
 Resolution set to fixed
 Status changed from positive_review to closed
Code didn't check attribute color. This is now done. Needs crossreview.
Apart from the colorissue, the code looks fine, so a positive_review as soon as the colorpart is accepted.
Last 10 new commits:
added another doctest (check length of elements)
renamed check_equal to equal
used equal in existing code (1 occurrence found, maybe there are more)
added is_monochromatic
Merge branch 'fsm/is_monochromatic' into t/16588/fsm/states_equality
fully_equal has now a compare_color flag
corrected handling of compare_color
== for finite state machines now handle comparing of colors better (monochromatic finite state machines are considered equal)
documented ==function for state colors (monochromatic)
added doctest to show behavior when states have colors