-
Notifications
You must be signed in to change notification settings - Fork 521
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Setting initial to list causes NestedGraphMachine to raise an exception #503
Comments
@thedrow |
There seems to be an issue with the resolving the names as @pkonnov points out. I maybe found another bug which is triggered when a state is added during on_enter/exit callbacks. I fixed that one in b8540bc. This works now: from transitions.extensions.factory import HierarchicalGraphMachine
class Model:
def __init__(self):
self.machine = HierarchicalGraphMachine(self, states=['A', 'B'], initial='A')
def on_enter_B(self):
child_1 = HierarchicalGraphMachine.state_cls(name='a')
child_2 = HierarchicalGraphMachine.state_cls(name='b')
child_3 = HierarchicalGraphMachine.state_cls(name='c')
state = HierarchicalGraphMachine.state_cls(name='C', initial=['a', 'b', 'c'])
state.add_substate([child_1, child_2, child_3])
self.machine.add_state(state)
self.to_C()
model = Model()
model.to_B()
assert model.state == ['C_a', 'C_b', 'C_c']
model.get_graph().draw('test.png', prog='dot') However, this might be unrelated to the bug you found. |
Ah wait, I misread @pkonnov answer. I think it should be possible to use list of strings/callables in any callback property. |
@aleneum yes, i also think that this is not related |
So either |
The parameter of this look weird:
A transition's |
So maybe I'm getting something wrong. Can't I enter two parallel states? |
Let's clarify the question: I can transition from multiple states to one state but I can't transition from one state to multiple states? |
if you refering to two different states then the answer is no. You can only use one destination right now. This state, however, can of course enter it's children in parallel where children's themselves might enter their children in parallel. When you set the destination to be a child, its siblings will not be entered. When I reworked the HSM, I actually tried to go that route (multiple dests mean parallel states) but hit a dead end somewhere.
When you specifiy multiple sources, Furthermore, the machine does not transition from multiple states to one state but only choses the transition with the currently most fitting source (e.g. |
But a state machine should be able to enter multiple parallel states even if they are not the initial states, no? I need to be able to model transitions from multiple states to multiple states. I now understand that's currently not supported and possibly hard to implement but I didn't understand it from the documentation at all. |
I agree, that this would be quite nice to have. That's why I tried to implement it. Without success though :(. Since parallel state support is quite rare across most FSM implementations I know, I opted to have limited parallel state support in
I am sorry to hear that there has been some confusion. Some features are not documented as they should be but if something like Closing this as it currently does not qualify as a bug. A separate feature request has been created. |
The text was updated successfully, but these errors were encountered: