pytransitions / transitions

A lightweight, object-oriented finite state machine implementation in Python with many extensions
MIT License
5.68k stars 530 forks source link

Fix add_ordered_transitions w/o initial state #392

Closed mkaranki closed 4 years ago

mkaranki commented 4 years ago

Previous implementation assumed that the initial state of the state machine must be specified in the states list.

However, the add_ordered_transitions could be useful also when only a part of the state machine is wanted to have ordered transactions. Think for example nested state machine where sub-states of a state is wanted to be traversed in order, perhaps in a loop.

To fix, allow calling add_ordered_transitions with states argument not including the initial state. In effect, loop_includes_initial argument has no relevance if the initial state is not present in the states list.

coveralls commented 4 years ago

Coverage Status

Coverage increased (+0.007%) to 98.471% when pulling 677ba98e447dcf944856aadcd8be012e2ea7a0aa on mkaranki:add_ordered_transactions_fix into 065eb38837377e690ed119bb4e3c7d53654d2447 on pytransitions:master.

aleneum commented 4 years ago

Hello @mkaranki,

thank you for this suggestion. This feature/fix will be part of transitions 0.8. I implemented it a bit differently though. I allowed myself to copy your test and hope that's fine with you.

Best regards!