All possible transitions are initialized, instead of those provided as an argument.
louisjmorgan opened this issue · 2 comments
Describe the bug
All possible transitions are initialized at the start, instead of only those specified.
Accordingly there is currently no way for me to check that a transition is valid before the state is changed.
Minimal working example
class Session(object):
pass
session = Session()
# Initialize state machine
machine = Machine(model=session, states=[
'solid', 'liquid', 'gas', 'plasma'], transitions=[{'trigger': 'melt', 'source': 'solid', 'dest': 'liquid'},], initial='solid')
print(machine.get_transitions())
output:
[<Transition('solid', 'solid')@140408192913552>, <Transition('liquid', 'solid')@140408192976656>, <Transition('gas', 'solid')@140408192978128>, <Transition('plasma', 'solid')@140408192980368>, <Transition('solid', 'liquid')@140408192977104>, <Transition('liquid', 'liquid')@140408192977424>, <Transition('gas', 'liquid')@140408192978512>, <Transition('plasma', 'liquid')@140408192980752>, <Transition('solid', 'gas')@140408192978960>, <Transition('liquid', 'gas')@140408192979280>, <Transition('gas', 'gas')@140408192979664>, <Transition('plasma', 'gas')@140408192981136>, <Transition('solid', 'plasma')@140408192981584>, <Transition('liquid', 'plasma')@140408192981904>, <Transition('gas', 'plasma')@140408192982288>, <Transition('plasma', 'plasma')@140408192982672>, <Transition('solid', 'liquid')@140408192983248>]
Expected behavior
I expect this to
A. show a single transition, the melt
one specified upon initialization.
Additional context
I have tried installing with pip, conda, and manually with setup.py, using versions 0.90, 0.90 and 0.91 respectively.
I realise now that I have to pass autoTransitions=false
upon initialization. Is there a complete api reference somewhere? I can't seem to find one.
Hello @louisjmorgan,
the currently available documentation can be found in the README and the code itself. For the code, we strive to document each class, method and parameter in a comprehensible way. The README introduces auto transitions and some of the side effects (e. g. for get_triggers
) but it's quite tough to spot weak spots in the documentation since we hardly use it (as you probably expected :)). If you think some matter requires a more extensive documentation, please let us know or create PR to deal with it.