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: sage-6.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:

Status badges


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 cheuberg

  • Status changed from new to needs_review

comment:2 Changed 8 years ago by dkrenn

  • Dependencies set to #16674

comment:3 Changed 8 years ago by dkrenn

  • Branch changed from u/cheuberg/fsm/states_equality to u/dkrenn/fsm/states_equality

comment:4 Changed 8 years ago by dkrenn

  • Authors changed from Clemens Heuberger to Clemens Heuberger, Daniel Krenn
  • Commit changed from f5b24c3d638ec739511a19c7c9b5513968e652bd to 0f4cd95d215f9368d0ea9ecea8cf9fb87ee77449
  • Reviewers set to Daniel Krenn

Code didn't check attribute color. This is now done. Needs cross-review.

Apart from the color-issue, the code looks fine, so a positive_review as soon as the color-part is accepted.

Last 10 new commits:

cc772e4added another doctest (check length of elements)
a12bf3crenamed check_equal to equal
4e4801eused equal in existing code (1 occurrence found, maybe there are more)
04579f3added is_monochromatic
afb1fafMerge branch 'fsm/is_monochromatic' into t/16588/fsm/states_equality
b8bee67fully_equal has now a compare_color flag
f595b25corrected handling of compare_color
e537338== for finite state machines now handle comparing of colors better (monochromatic finite state machines are considered equal)
4bd7fb0documented ==-function for state colors (monochromatic)
0f4cd95added doctest to show behavior when states have colors

comment:5 Changed 8 years ago by cheuberg

  • Branch changed from u/dkrenn/fsm/states_equality to u/cheuberg/fsm/states_equality

comment:6 Changed 8 years ago by git

  • Commit changed from 0f4cd95d215f9368d0ea9ecea8cf9fb87ee77449 to 0f3a40eec3031f7175a4502591e8fedb04e99ee2

Branch pushed to git repo; I updated commit sha1. New commits:

dc5e17eMinor correction in docstring (``...``)
77f3804Minor rewording in docstring
063fb45Merge remote-tracking branch 'aau/fsm/process-refuse-nondeterministic' (#16539) into t/16675/fsm/check_equal
1d730feMerge branch 'u/cheuberg/fsm/check_equal' of into t/16674/fsm/is_monochromatic
0f3a40eMerge branch 'u/cheuberg/fsm/is_monochromatic' of into fsm/states_equality

comment:7 Changed 8 years ago by cheuberg

  • Reviewers changed from Daniel Krenn to Daniel Krenn, Clemens Heuberger
  • Status changed from needs_review to positive_review

Cross-reviewed 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 vbraun

  • Branch changed from u/cheuberg/fsm/states_equality to 0f3a40eec3031f7175a4502591e8fedb04e99ee2
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.