<jupyter_start><jupyter_text>Passing Data to ActionsIt is possible to pass data into a state machine as part of a signal trigger, so that the data can be used by an action. For that, make sure three parts are in place:* The action can declare arguments (args) and keyword arguments (kwargs) in the Python code.* The action is referred to in the transition with a `(*)` that signals to STMPY to pass on the arguments that it receives from the signal trigger.* The signal trigger is dispatched as usual using the driver's or the state machine's `send` method. The `send`method allows to pass through the data, using the parameters `args` and `kwargs`.Have a look below for a minimal example. (The state machine does not do anything useful.)<jupyter_code>from stmpy import Driver, Machine

class Logic:
    def m1(self):
        print("m1")

    def m2(self, a):
        print("m2 with {}".format(a))

    def m3(self, a, b):
        print("m3 with {} and {}".format(a, b))

    def m4(self, b=1):
        print("m3 with {}".format(b))

    def m5(self, a, b=1):
        print("m3 with {} and {}".format(a, b))


logic = Logic()

t0 = {"source": "initial", "target": "idle"}

# we declare a few self-transition, which just call the method with
# different arguments
t1 = {"trigger": "s1", "source": "idle", "target": "idle", "effect": "m1(*)"}
t2 = {"trigger": "s2", "source": "idle", "target": "idle", "effect": "m2(*)"}
t3 = {"trigger": "s3", "source": "idle", "target": "idle", "effect": "m3(*)"}
t4 = {"trigger": "s4", "source": "idle", "target": "idle", "effect": "m4(*)"}
t5 = {"trigger": "s5", "source": "idle", "target": "idle", "effect": "m5(*)"}

machine = Machine(name="logic", transitions=[t0, t1, t2, t3, t4, t5], obj=logic)
logic.stm = machine

driver = Driver()
driver.add_machine(machine)
driver.start()

# here we actually send the signals that transport the data taken
# as arguments into the method
machine.send("s1")
machine.send("s2", args=[2])
machine.send("s3", args=[2, 3])
machine.send("s4", kwargs={"b": 3})
machine.send("s5", args=[2], kwargs={"b": 3})<jupyter_output>m1
m2 with 2
m3 with 2 and 3
m3 with 3
m3 with 2 and 3
{'fraction_non_alphanumeric': 0.16868592730661697, 'fraction_numerical': 0.0260950605778192, 'mean_word_length': 4.421717171717172, 'pattern_counts': {'":': 24, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '352449', 'license': 'MIT', 'n_tokens_mistral': 733, 'n_tokens_neox': 720, 'n_words': 287, 'path': 'Passing Data to Actions.ipynb', 'repo_name': 'falkr/stmpy-ttm4115', 'size': '2146'}