Skip to content

How do I diagram an existing Machine for debugging? #629

Answered by aleneum
leingang asked this question in Q&A
Discussion options

You must be logged in to vote

Hello @leingang,

If I have an existing Machine, how can I create a GraphMachine with the same states and transitions, and diagram that?

unfortunately, transitions does not feature a copy constructor or method (yet). HierarchicalMachine does some shallow copying but expects the copied/embedded machine to be of the same class. GraphMachine and Machine are mostly the same. You could get a diagram from a temporary GraphMachine by shallow copying/assigning the relevant properties of your machine to the graph machine:

from transitions.extensions import GraphMachine
from transitions import Machine

m = Machine(states=["A", "B", "C", "D"], initial="C")
m.add_ordered_transitions(trigger="next", c…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@leingang
Comment options

Answer selected by leingang
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants