output
stringlengths
1
928k
instruction
stringlengths
7
928k
system
stringlengths
0
104k
Stops the execution of the current state machine.
Make a summary of the following Python 3 code def stop(self): logger.debug("Stop the state machine execution ...") if self.state_machine_manager.get_active_state_machine() is not None: self.state_machine_manager.get_active_state_machine().root_state.recursively_preempt_states() self....
You are a Python code architect, reviewing and designing scalable and efficient code
Blocking wait for the execution to finish
Can you tell what is the following Python 3 function doing def join(self, timeout=None): if self.__wait_for_finishing_thread: if not timeout: # signal handlers won't work if timeout is None and the thread is joined while True: self.__wait_for_finis...
As a python code expert, you are capable of creating scripts from specifications.
def _run_active_state_machine(self): """Store running state machine and observe its status """ # Create new concurrency queue for root state to be able to synchronize with the execution self.__running_state_machine = self.state_machine_manager.get_active_state_machine() if not s...
Can you create a Python 3 function that runs the active state machine and observe its status
As a python code expert, you are capable of creating scripts from specifications.
Observe running state machine and stop engine if execution has finished
Here you have a function in Python 3, explain what it does def _wait_for_finishing(self): self.state_machine_running = True self.__running_state_machine.join() self.__set_execution_mode_to_finished() self.state_machine_manager.active_state_machine_id = None plugins.run_on_state_m...
As a python code expert, you are capable of creating scripts from specifications.
def backward_step(self): """Take a backward step for all active states in the state machine """ logger.debug("Executing backward step ...") self.run_to_states = [] self.set_execution_mode(StateMachineExecutionStatus.BACKWARD)
Write a Python 3 script for taking a backward step for all active states in the state machine
You are a Python code architect, reviewing and designing scalable and efficient code
Set the execution mode to stepping mode.
Here you have a function in Python 3, explain what it does def step_mode(self, state_machine_id=None): logger.debug("Activate step mode") if state_machine_id is not None: self.state_machine_manager.active_state_machine_id = state_machine_id self.run_to_states = [] if self.f...
You are a Python code analyst, evaluating scripts for potential improvements.
def step_into(self): """Take a forward step (into) for all active states in the state machine """ logger.debug("Execution step into ...") self.run_to_states = [] if self.finished_or_stopped(): self.set_execution_mode(StateMachineExecutionStatus.FORWARD_INTO) ...
Write a Python 3 function that can take a forward step into for all active states in the state machine.
As a Python code analyst, you investigate and solve complex coding mysteries
Take a forward step over for all active states in the state machine.
Given the following Python 3 function, write the documentation def step_over(self): logger.debug("Execution step over ...") self.run_to_states = [] if self.finished_or_stopped(): self.set_execution_mode(StateMachineExecutionStatus.FORWARD_OVER) self._run_active_state_mach...
You are a Python code analyst, evaluating scripts for potential improvements.
def step_out(self): """Take a forward step (out) for all active states in the state machine """ logger.debug("Execution step out ...") self.run_to_states = [] if self.finished_or_stopped(): self.set_execution_mode(StateMachineExecutionStatus.FORWARD_OUT) s...
Implement a function in Python 3 to take a forward step for all active states in the state machine and run the active state machine.
You are a Python code architect, reviewing and designing scalable and efficient code
def run_to_selected_state(self, path, state_machine_id=None): """Execute the state machine until a specific state. This state won't be executed. This is an asynchronous task """ if self.state_machine_manager.get_active_state_machine() is not None: self.state_machine_manager.get_activ...
Implement a Python 3 function for executing the state machine until a specific state.
As a Python code composer, you craft elegant and concise scripts.
def _wait_while_in_pause_or_in_step_mode(self): """ Waits as long as the execution_mode is in paused or step_mode """ while (self._status.execution_mode is StateMachineExecutionStatus.PAUSED) \ or (self._status.execution_mode is StateMachineExecutionStatus.STEP_MODE): ...
Implement a Python 3 function for waiting as long as the execution_mode is in paused or step_mode.
As a python code expert, you are capable of creating scripts from specifications.
def _wait_if_required(self, container_state, next_child_state_to_execute, woke_up_from_pause_or_step_mode): """ Calls a blocking wait for the calling thread, depending on the execution mode. :param container_state: the current hierarhcy state to handle the execution mode for :param next_child_s...
Write a Python 3 function that can check if the calling thread is blocking and waits for the execution of the current state.
As a Python code translator, you convert algorithms and pseudocode into Python.
Checks the current execution status and returns it.
Can you generate the documentation for the following Python 3 function def handle_execution_mode(self, container_state, next_child_state_to_execute=None): self.state_counter_lock.acquire() self.state_counter += 1 # logger.verbose("Increase state_counter!" + str(self.state_counter)) self....
You are a Python code architect, reviewing and designing scalable and efficient code
def _modify_run_to_states(self, state): """ This is a special case. Inside a hierarchy state a step_over is triggered and affects the last child. In this case the self.run_to_states has to be modified in order to contain the parent of the hierarchy state. Otherwise the execution won't re...
Write a Python 3 script to modify the run_to_states list for the given state.
As a Python code translator, you convert algorithms and pseudocode into Python.
An observed setter for the execution mode of the state machine status.
Can you generate the documentation for the following Python 3 function def set_execution_mode(self, execution_mode, notify=True): if not isinstance(execution_mode, StateMachineExecutionStatus): raise TypeError("status must be of type StateMachineExecutionStatus") self._status.execution_mode ...
You are a Python code analyst, evaluating scripts for potential improvements.
def recursively_preempt_states(self): """ Preempt the state and all of it child states. """ super(ContainerState, self).recursively_preempt_states() # notify the transition condition variable to let the state instantaneously stop self._transitions_cv.acquire() self._trans...
Write a Python 3 script for preempting the state and all of it child states.
As a Python code translator, you convert algorithms and pseudocode into Python.
def recursively_pause_states(self): """ Pause the state and all of it child states. """ super(ContainerState, self).recursively_pause_states() for state in self.states.values(): state.recursively_pause_states()
Can you create a Python 3 function that pauses the state and all of it child states.
As a python code expert, you are capable of creating scripts from specifications.
def recursively_resume_states(self): """ Resume the state and all of it child states. """ super(ContainerState, self).recursively_resume_states() for state in self.states.values(): state.recursively_resume_states()
Can you create a Python 3 function that resumes the state and all of it child states.
As a python code expert, you are capable of creating scripts from specifications.
def setup_run(self): """ Executes a generic set of actions that has to be called in the run methods of each derived state class. :return: """ super(ContainerState, self).setup_run() # reset the scoped data self._scoped_data = {} self._start_state_modified = False...
Write a Python 3 script for setting up the scoped data for the current state class.
As a Python code translator, you convert algorithms and pseudocode into Python.
def handle_no_start_state(self): """Handles the situation, when no start state exists during execution The method waits, until a transition is created. It then checks again for an existing start state and waits again, if this is not the case. It returns the None state if the the state machine w...
Write a Python 3 script for handling the situation when no start state exists during execution
You are a Python code generator, capable of creating scripts from specifications.
def group_states(self, state_ids, scoped_variable_ids=None): """ Group states and scoped variables into a new hierarchy state and remain internal connections. Interconnecting transitions and data flows to parent and other child states are removed, at the moment. :param state_ids: state_id's...
Can you write a function in Python 3 where it groups states and scoped variables into a new hierarchy state.
As a python code expert, you are capable of creating scripts from specifications.
Adds a state to the container state.
Given the following Python 3 function, write the documentation def add_state(self, state, storage_load=False): assert isinstance(state, State) # logger.info("add state {}".format(state)) # handle the case that the child state id is the same as the container state id or future sibling state id ...
As a python code expert, you are capable of creating scripts from specifications.
Removes a state from the container state.
Explain what the following Python 3 code does def remove_state(self, state_id, recursive=True, force=False, destroy=True): if state_id not in self.states: raise AttributeError("State_id %s does not exist" % state_id) if state_id == self.start_state_id: self.set_start_state(None)...
As a Python code translator, you convert algorithms and pseudocode into Python.
Removes all the state elements.
Can you generate a brief explanation for the following Python 3 code def destroy(self, recursive): for transition_id in list(self.transitions.keys()): self.remove_transition(transition_id, destroy=recursive) for data_flow_id in list(self.data_flows.keys()): self.remove_data_flow(...
As a Python code translator, you convert algorithms and pseudocode into Python.
def related_linkage_state(self, state_id): """ TODO: document """ related_transitions = {'external': {'ingoing': [], 'outgoing': []}, 'internal': {'enclosed': [], 'ingoing': [], 'outgoing': []}} related_data_flows = {'external': {'ingoing': [], 'outgoing':...
Implement a Python 3 function for returning a tuple of related_transitions related_data_flows and related_internal_transitions for the given state_id.
As a Python code composer, you craft elegant and concise scripts.
This function returns a list of related linkage states and scoped variables.
Can you tell what is the following Python 3 function doing def related_linkage_states_and_scoped_variables(self, state_ids, scoped_variables): # find all related transitions related_transitions = {'enclosed': [], 'ingoing': [], 'outgoing': []} for t in self.transitions.values(): # c...
As a python code expert, you are capable of creating scripts from specifications.
Changes the type of the state to another type
Here you have a function in Python 3, explain what it does def change_state_type(self, state, new_state_class): from rafcon.gui.helpers.state import create_new_state_from_state_with_type state_id = state.state_id if state_id not in self.states: raise ValueError("State '{0}' with id...
You are a Python code architect, reviewing and designing scalable and efficient code
def set_start_state(self, state): """Sets the start state of a container state :param state: The state_id of a state or a direct reference ot he state (that was already added to the container) that will be the start state of this container state. """ if state is Non...
Write a Python 3 function that can set the start state of a container state
You are a Python code analyst, evaluating scripts for potential improvements.
Get the start state of the container state.
How would you explain what the following Python 3 function does def get_start_state(self, set_final_outcome=False): # overwrite the start state in the case that a specific start state is specific e.g. by start_from_state if self.get_path() in state_machine_execution_engine.start_state_paths: ...
As a python code expert, you are capable of creating scripts from specifications.
def remove(self, state_element, recursive=True, force=False, destroy=True): """Remove item from state :param StateElement state_element: State or state element to be removed :param bool recursive: Only applies to removal of state and decides whether the removal should be called recu...
Can you create a Python 3 function that removes the state element from the container state.
As a Python code composer, you craft elegant and concise scripts.
Checks the transition id and calculates a new one if it does not exist.
Can you generate the documentation for the following Python 3 function def check_transition_id(self, transition_id): if transition_id is not None: if transition_id in self._transitions.keys(): raise AttributeError("The transition id %s already exists. Cannot add transition!", transit...
As a Python code analyst, you investigate and solve complex coding mysteries
check if outcome of from state is not already connected to the transition to
How would you explain what the following Python 3 function does def check_if_outcome_already_connected(self, from_state_id, from_outcome): for trans_key, transition in self.transitions.items(): if transition.from_state == from_state_id: if transition.from_outcome == from_outcome: ...
As a python code expert, you are capable of creating scripts from specifications.
def create_transition(self, from_state_id, from_outcome, to_state_id, to_outcome, transition_id): """ Creates a new transition. Lookout: Check the parameters first before creating a new transition :param from_state_id: The source state of the transition :param from_outcome: The outcome...
How would you code a function in Python 3 to create a new transition.
You are a Python code architect, reviewing and designing scalable and efficient code
Adds a transition to the container state
Make a summary of the following Python 3 code def add_transition(self, from_state_id, from_outcome, to_state_id, to_outcome, transition_id=None): transition_id = self.check_transition_id(transition_id) # Set from_state_id to None for start transitions, as from_state_id and from_outcome should both be ...
As a Python code analyst, you investigate and solve complex coding mysteries
Determines the next transition for the given outcome.
Can you generate a brief explanation for the following Python 3 code def get_transition_for_outcome(self, state, outcome): if not isinstance(state, State): raise TypeError("state must be of type State") if not isinstance(outcome, Outcome): raise TypeError("outcome must be of type...
As a Python code composer, you craft elegant and concise scripts.
Removes a transition from the container state.
Can you generate the documentation for the following Python 3 function def remove_transition(self, transition_id, destroy=True): if transition_id == -1 or transition_id == -2: raise AttributeError("The transition_id must not be -1 (Aborted) or -2 (Preempted)") if transition_id not in self._t...
You are a Python code architect, reviewing and designing scalable and efficient code
Removes the outcome from the internal state.
Here you have a function in Python 3, explain what it does def remove_outcome_hook(self, outcome_id): for transition_id in list(self.transitions.keys()): transition = self.transitions[transition_id] if transition.to_outcome == outcome_id and transition.to_state == self.state_id: ...
As a Python code composer, you craft elegant and concise scripts.
def check_data_flow_id(self, data_flow_id): """ Check the data flow id and calculate a new one if its None :param data_flow_id: The data flow id to check :return: The new data flow id :raises exceptions.AttributeError: if data_flow.data_flow_id already exists """ if data...
Write a Python 3 function for checking the data flow id and calculate a new one if it does not exist.
As a Python code translator, you convert algorithms and pseudocode into Python.
Adds a data flow to the container state
Can you generate a brief explanation for the following Python 3 code def add_data_flow(self, from_state_id, from_data_port_id, to_state_id, to_data_port_id, data_flow_id=None): data_flow_id = self.check_data_flow_id(data_flow_id) self.data_flows[data_flow_id] = DataFlow(from_state_id, from_data_port_id...
You are a Python code analyst, evaluating scripts for potential improvements.
Removes a data flow from the container state
Can you generate the documentation for the following Python 3 function def remove_data_flow(self, data_flow_id, destroy=True): if data_flow_id not in self._data_flows: raise AttributeError("The data_flow_id %s does not exist" % str(data_flow_id)) self._data_flows[data_flow_id].parent = None...
As a Python code translator, you convert algorithms and pseudocode into Python.
Removes all data flows with the passed data_port_id from the state.
Here you have a function in Python 3, explain what it does def remove_data_flows_with_data_port_id(self, data_port_id): # delete all data flows in parent related to data_port_id and self.state_id = external data flows # checking is_root_state_of_library is only necessary in case of scoped variables, as ...
You are a Python code generator, capable of creating scripts from specifications.
def get_scoped_variable_from_name(self, name): """ Get the scoped variable for a unique name :param name: the unique name of the scoped variable :return: the scoped variable specified by the name :raises exceptions.AttributeError: if the name is not in the the scoped_variables dictionar...
Can you create a Python 3 function that gets the scoped variable for a unique name
As a Python code analyst, you investigate and solve complex coding mysteries
Adds a scoped variable to the state.
Here you have a function in Python 3, explain what it does def add_scoped_variable(self, name, data_type=None, default_value=None, scoped_variable_id=None): if scoped_variable_id is None: # All data port ids have to passed to the id generation as the data port id has to be unique inside a state ...
As a Python code translator, you convert algorithms and pseudocode into Python.
def remove_scoped_variable(self, scoped_variable_id, destroy=True): """Remove a scoped variable from the container state :param scoped_variable_id: the id of the scoped variable to remove :raises exceptions.AttributeError: if the id of the scoped variable already exists """ if s...
Create a Python 3 function to remove a scoped variable from the container state.
As a Python code composer, you craft elegant and concise scripts.
Searches for a data port in the state with the specified id and returns the data port object.
Make a summary of the following Python 3 code def get_data_port(self, state_id, port_id): if state_id == self.state_id: return self.get_data_port_by_id(port_id) for child_state_id, child_state in self.states.items(): if state_id != child_state_id: continue ...
You are a Python code architect, reviewing and designing scalable and efficient code
Search for the given data port id in the state and return the data port with the searched id or None if not found.
Can you tell what is the following Python 3 function doing def get_data_port_by_id(self, data_port_id): data_port = super(ContainerState, self).get_data_port_by_id(data_port_id) if data_port: return data_port if data_port_id in self.scoped_variables: return self.scoped_va...
You are a Python code generator, capable of creating scripts from specifications.
Retrieves all input data for a state
Can you tell what is the following Python 3 function doing def get_inputs_for_state(self, state): result_dict = {} tmp_dict = self.get_default_input_values_for_state(state) result_dict.update(tmp_dict) for input_port_key, value in state.input_data_ports.items(): # for all i...
As a Python code analyst, you investigate and solve complex coding mysteries
def add_input_data_to_scoped_data(self, dictionary): """Add a dictionary to the scoped data As the input_data dictionary maps names to values, the functions looks for the proper data_ports keys in the input_data_ports dictionary :param dictionary: The dictionary that is added to the sc...
Can you create a Python 3 function that adds a dictionary to the scoped data
As a python code expert, you are capable of creating scripts from specifications.
Adds a state execution output to the scoped data
Explain what the following Python 3 code does def add_state_execution_output_to_scoped_data(self, dictionary, state): for output_name, value in dictionary.items(): for output_data_port_key, data_port in list(state.output_data_ports.items()): if output_name == data_port.name: ...
As a Python code translator, you convert algorithms and pseudocode into Python.
Add the default values of the scoped variables to the scoped data dictionary
Here you have a function in Python 3, explain what it does def add_default_values_of_scoped_variables_to_scoped_data(self): for key, scoped_var in self.scoped_variables.items(): self.scoped_data[str(scoped_var.data_port_id) + self.state_id] = \ ScopedData(scoped_var.name, scoped_var....
You are a Python code generator, capable of creating scripts from specifications.
def update_scoped_variables_with_output_dictionary(self, dictionary, state): """Update the values of the scoped variables with the output dictionary of a specific state. :param: the dictionary to update the scoped variables with :param: the state the output dictionary belongs to """ ...
Create a Python 3 function for updating the values of the scoped variables with the output dictionary of a specific state.
You are a Python code analyst, evaluating scripts for potential improvements.
Changes the id of the state of the container state to a new id. This function replaces the old state_id with the new state_id in all the state tables and data flows and transitions.
Can you generate a brief explanation for the following Python 3 code def change_state_id(self, state_id=None): old_state_id = self.state_id super(ContainerState, self).change_state_id(state_id) # Use private variables to change ids to prevent validity checks # change id in all transition...
As a Python code composer, you craft elegant and concise scripts.
def get_state_for_transition(self, transition): """Calculate the target state of a transition :param transition: The transition of which the target state is determined :return: the to-state of the transition :raises exceptions.TypeError: if the transition parameter is of wrong type ...
Can you implement a function in Python 3 that calculates the target state of a transition
As a python code expert, you are capable of creating scripts from specifications.
Write the scoped data to output of the container state.
Can you generate the documentation for the following Python 3 function def write_output_data(self, specific_output_dictionary=None): if isinstance(specific_output_dictionary, dict): output_dict = specific_output_dictionary else: output_dict = self.output_data for output_...
As a Python code composer, you craft elegant and concise scripts.
Check validity of passed child object
Can you generate the documentation for the following Python 3 function def check_child_validity(self, child): # First let the state do validity checks for outcomes and data ports valid, message = super(ContainerState, self).check_child_validity(child) if not valid and not message.startswith("Inv...
As a Python code translator, you convert algorithms and pseudocode into Python.
def check_data_port_connection(self, check_data_port): """Checks the connection validity of a data port The method is called by a child state to check the validity of a data port in case it is connected with data flows. The data port does not belong to 'self', but to one of self.states. ...
Implement a function in Python 3 to check the validity of a data port
As a Python code composer, you craft elegant and concise scripts.
Checks the validity of a data port id
Here you have a function in Python 3, explain what it does def _check_data_port_id(self, data_port): # First check inputs and outputs valid, message = super(ContainerState, self)._check_data_port_id(data_port) if not valid: return False, message # Container state also has sco...
As a python code expert, you are capable of creating scripts from specifications.
def _check_data_port_name(self, data_port): """Checks the validity of a data port name Checks whether the name of the given data port is already used by anther data port within the state. Names must be unique with input data ports, output data ports and scoped variables. :param rafcon....
Can you write a function in Python 3 where it checks the validity of a data port name
As a python code expert, you are capable of creating scripts from specifications.
Checks the validity of a data flow
Explain what the following Python 3 code does def _check_data_flow_validity(self, check_data_flow): valid, message = self._check_data_flow_id(check_data_flow) if not valid: return False, message valid, message = self._check_data_flow_ports(check_data_flow) if not valid: ...
You are a Python code analyst, evaluating scripts for potential improvements.
def _check_data_flow_id(self, data_flow): """Checks the validity of a data flow id Checks whether the id of the given data flow is already by anther data flow used within the state. :param rafcon.core.data_flow.DataFlow data_flow: The data flow to be checked :return bool validity, str ...
Can you write a function in Python 3 where it checks the validity of a data flow id
You are a Python code architect, reviewing and designing scalable and efficient code
Checks the validity of the ports of a data flow
Given the following Python 3 function, write the documentation def _check_data_flow_ports(self, data_flow): from_state_id = data_flow.from_state to_state_id = data_flow.to_state from_data_port_id = data_flow.from_key to_data_port_id = data_flow.to_key # Check whether to and from...
As a python code expert, you are capable of creating scripts from specifications.
def _check_data_flow_types(self, check_data_flow): """Checks the validity of the data flow connection Checks whether the ports of a data flow have matching data types. :param rafcon.core.data_flow.DataFlow check_data_flow: The data flow to be checked :return bool validity, str message:...
Implement a Python 3 function for checking the validity of the data flow connection
As a Python code translator, you convert algorithms and pseudocode into Python.
Checks the validity of a transition.
How would you explain what the following Python 3 function does def _check_transition_validity(self, check_transition): valid, message = self._check_transition_id(check_transition) if not valid: return False, message # Separate check for start transitions if check_transition...
As a python code expert, you are capable of creating scripts from specifications.
Checks whether the transition id is already used by another transition within the state
Can you generate a brief explanation for the following Python 3 code def _check_transition_id(self, transition): transition_id = transition.transition_id if transition_id in self.transitions and transition is not self.transitions[transition_id]: return False, "transition_id already existing"...
As a python code expert, you are capable of creating scripts from specifications.
def _check_start_transition(self, start_transition): """Checks the validity of a start transition Checks whether the given transition is a start transition a whether it is the only one within the state. :param rafcon.core.transition.Transition start_transition: The transition to be checked ...
Write a Python 3 function that can check whether the given transition is a start transition
You are a Python code generator, capable of creating scripts from specifications.
def _check_transition_target(self, transition): """Checks the validity of a transition target Checks whether the transition target is valid. :param rafcon.core.transition.Transition transition: The transition to be checked :return bool validity, str message: validity is True, when the ...
Implement a function in Python 3 to check the validity of a transition target
As a Python code composer, you craft elegant and concise scripts.
def _check_transition_origin(self, transition): """Checks the validity of a transition origin Checks whether the transition origin is valid. :param rafcon.core.transition.Transition transition: The transition to be checked :return bool validity, str message: validity is True, when the ...
Implement a function in Python 3 to check the validity of a transition origin
You are a Python code architect, reviewing and designing scalable and efficient code
def _check_transition_connection(self, check_transition): """Checks the validity of a transition connection Checks whether the transition is allowed to connect the origin with the target. :param rafcon.core.transition.Transition check_transition: The transition to be checked :return bo...
How would you code a function in Python 3 to check the validity of a transition connection
As a python code expert, you are capable of creating scripts from specifications.
def get_states_statistics(self, hierarchy_level): """ Returns the numer of child states :return: """ number_of_all_child_states = 0 max_child_hierarchy_level = 0 for s in self.states.values(): child_hierarchy_level = 0 number_of_child_state...
Can you create a Python 3 function that returns the numer of child states and the maximal child states.
As a Python code composer, you craft elegant and concise scripts.
def get_number_of_transitions(self): """ Returns the numer of child states :return: """ number_of_all_transitions = 0 for s in self.states.values(): number_of_all_transitions += s.get_number_of_transitions() return number_of_all_transitions + len(self....
Write a Python 3 script for returning the number of child states that are in the same state.
You are a Python code analyst, evaluating scripts for potential improvements.
Returns the id of the first state in which the first transition goes to.
Here you have a function in Python 3, explain what it does def start_state_id(self): for transition_id in self.transitions: if self.transitions[transition_id].from_state is None: to_state = self.transitions[transition_id].to_state if to_state is not None: ...
As a Python code translator, you convert algorithms and pseudocode into Python.
def start_state_id(self, start_state_id, to_outcome=None): """Set the start state of the container state See property :param start_state_id: The state id of the state which should be executed first in the Container state :raises exceptions.ValueError: if the start_state_id does not exi...
Can you implement a function in Python 3 that sets the start state of the container state.
As a Python code translator, you convert algorithms and pseudocode into Python.
Setter for _scoped_variables field MimeType
Can you generate the documentation for the following Python 3 function def scoped_variables(self, scoped_variables): if not isinstance(scoped_variables, dict): raise TypeError("scoped_variables must be of type dict") if [sv_id for sv_id, sv in scoped_variables.items() if not isinstance(sv, S...
As a Python code composer, you craft elegant and concise scripts.
def _execute(self, execute_inputs, execute_outputs, backward_execution=False): """Calls the custom execute function of the script.py of the state """ self._script.build_module() outcome_item = self._script.execute(self, execute_inputs, execute_outputs, backward_execution) # in...
Create a Python 3 function for calling the custom execute function of the state object and returns the result of the execution.
As a Python code analyst, you investigate and solve complex coding mysteries
This method executes the state and returns the result of the execution.
Can you generate the documentation for the following Python 3 function def run(self): if self.is_root_state: self.execution_history.push_call_history_item(self, CallType.EXECUTE, None, self.input_data) logger.debug("Running {0}{1}".format(self, " (backwards)" if self.backward_execution else...
As a Python code translator, you convert algorithms and pseudocode into Python.
Called when the view was registered
Can you generate the documentation for the following Python 3 function def register_view(self, view): super(StateMachineTreeController, self).register_view(view) self.view.connect('button_press_event', self.mouse_click) self.view_is_registered = True self.update(with_expand=True)
You are a Python code generator, capable of creating scripts from specifications.
Register callback methods for triggered actions
Explain what the following Python 3 code does def register_actions(self, shortcut_manager): shortcut_manager.add_callback_for_action("delete", self._delete_selection) shortcut_manager.add_callback_for_action("add", partial(self._add_new_state, state_type=StateType.EXECUTION)) shortcut_manager.ad...
As a python code expert, you are capable of creating scripts from specifications.
Change the state machine that is observed for new selected states to the selected state machine.
Given the following Python 3 function, write the documentation def register(self): self._do_selection_update = True # relieve old model if self.__my_selected_sm_id is not None: # no old models available self.relieve_model(self._selected_sm_model) # set own selected state mac...
As a Python code analyst, you investigate and solve complex coding mysteries
Callback method for paste action
Here you have a function in Python 3, explain what it does def paste_action_callback(self, *event): if react_to_event(self.view, self.tree_view, event): sm_selection, _ = self.get_state_machine_selection() # only list specific elements are cut by widget if len(sm_selection.st...
As a python code expert, you are capable of creating scripts from specifications.
def _add_new_state(self, *event, **kwargs): """Triggered when shortcut keys for adding a new state are pressed, or Menu Bar "Edit, Add State" is clicked. Adds a new state only if the the state machine tree is in focus. """ if react_to_event(self.view, self.view['state_machine_tree_view'...
Write a Python 3 script for triggering when the add new state is clicked.
As a Python code analyst, you investigate and solve complex coding mysteries
Notify state machine about tree view selection
How would you explain what the following Python 3 function does def selection_changed(self, widget, event=None): # do not forward cursor selection updates if state update is running # TODO maybe make this generic for respective abstract controller if self._state_which_is_updated: ret...
As a Python code translator, you convert algorithms and pseudocode into Python.
def redo_expansion_state(self, ignore_not_existing_rows=False): """ Considers the tree to be collapsed and expand into all tree item with the flag set True """ def set_expansion_state(state_path): state_row_iter = self.state_row_iter_dict_by_state_path[state_path] if state_row_i...
Create a Python 3 function for considering the tree to be collapsed and expand into all tree items with the flag set True
As a Python code analyst, you investigate and solve complex coding mysteries
Updates the state - model of the current state - model with the new state - model of the current state - model.
Can you generate the documentation for the following Python 3 function def update(self, changed_state_model=None, with_expand=False): if not self.view_is_registered: return # define initial state-model for update if changed_state_model is None: # reset all pa...
As a python code expert, you are capable of creating scripts from specifications.
Check if the state machine tree specific show content flag is set.
Given the following Python 3 function, write the documentation def show_content(self, state_model): upper_most_lib_state_m = None if isinstance(state_model, LibraryStateModel): uppermost_library_root_state = state_model.state.get_uppermost_library_root_state() if uppermost_librar...
You are a Python code analyst, evaluating scripts for potential improvements.
def insert_and_update_recursively(self, parent_iter, state_model, with_expand=False): """ Insert and/or update the handed state model in parent tree store element iterator :param parent_iter: Parent tree store iterator the insert should be performed in :param StateModel state_model: Model of st...
Can you write a function in Python 3 where it inserts and update the handed state model in the tree store element iteratorparent_iter.
You are a Python code generator, capable of creating scripts from specifications.
Getter state machine selection
Can you generate the documentation for the following Python 3 function def get_state_machine_selection(self): if self._selected_sm_model: return self._selected_sm_model.selection, self._selected_sm_model.selection.states else: return None, set()
As a Python code composer, you craft elegant and concise scripts.
def _handle_double_click(self, event): """ Double click with left mouse button focuses the state and toggles the collapse status""" if event.get_button()[1] == 1: # Left mouse button path_info = self.tree_view.get_path_at_pos(int(event.x), int(event.y)) if path_info: # Valid en...
Write a Python 3 script to double click event handler
As a Python code analyst, you investigate and solve complex coding mysteries
def execute(self, state, inputs=None, outputs=None, backward_execution=False): """Execute the user 'execute' function specified in the script :param ExecutionState state: the state belonging to the execute function, refers to 'self' :param dict inputs: the input data of the script :para...
Implement a Python 3 function for executing the user execute function specified in the script
As a Python code analyst, you investigate and solve complex coding mysteries
def _load_script(self): """Loads the script from the filesystem :raises exceptions.IOError: if the script file could not be opened """ script_text = filesystem.read_file(self.path, self.filename) if not script_text: raise IOError("Script file could not be opened or ...
Write a Python 3 function for loading the script from the filesystem
You are a Python code generator, capable of creating scripts from specifications.
def build_module(self): """Builds a temporary module from the script file :raises exceptions.IOError: if the compilation of the script module failed """ try: imp.acquire_lock() module_name = os.path.splitext(self.filename)[0] + str(self._script_id) #...
Write a Python 3 script for building a temporary module from the script file and returns the module object.
You are a Python code analyst, evaluating scripts for potential improvements.
def register_view(self, view): """Called when the View was registered""" super(MenuBarController, self).register_view(view) data_flow_mode = global_runtime_config.get_config_value("DATA_FLOW_MODE", False) view["data_flow_mode"].set_active(data_flow_mode) show_data_flows = global...
Implement a function in Python 3 to call when the View was registered
As a python code expert, you are capable of creating scripts from specifications.
Callback when a config value has been changed
Make a summary of the following Python 3 code def on_config_value_changed(self, config_m, prop_name, info): config_key = info['args'][1] # config_value = info['args'][2] if config_key == "LIBRARY_PATHS": library_manager.refresh_libraries() elif config_key == "SHORTCUTS": ...
As a Python code analyst, you investigate and solve complex coding mysteries
Method update the recent opened state machines list.
Can you generate the documentation for the following Python 3 function def _update_recently_opened_state_machines(self): if not self.registered_view: return for item in self.view.sub_menu_open_recently.get_children(): self.view.sub_menu_open_recently.remove(item) menu_i...
You are a Python code generator, capable of creating scripts from specifications.
Function to display the currently selected state machine in full screen mode
Here you have a function in Python 3, explain what it does def on_full_screen_activate(self, *args): self.sm_notebook.set_show_tabs(False) self.main_window_view['graphical_editor_vbox'].remove(self.sm_notebook) self.full_screen_window.add(self.sm_notebook) position = self.main_window_vie...
As a Python code translator, you convert algorithms and pseudocode into Python.
Unregister all registered functions to a view element
Make a summary of the following Python 3 code def unregister_view(self): for handler_id in self.handler_ids.keys(): self.view[handler_id].disconnect(self.handler_ids[handler_id])
As a Python code translator, you convert algorithms and pseudocode into Python.
def register_actions(self, shortcut_manager): """Register callback methods for triggered actions :param rafcon.gui.shortcut_manager.ShortcutManager shortcut_manager: Shortcut Manager Object holding mappings between shortcuts and actions. """ self.add_callback_to_shortcut_man...
Can you implement a function in Python 3 that registers callback methods for triggered actions in the given shortcuts.
As a Python code composer, you craft elegant and concise scripts.
Helper function to add a callback to the shortcut manager.
Explain what the following Python 3 code does def add_callback_to_shortcut_manager(self, action, callback): if action not in self.registered_shortcut_callbacks: self.registered_shortcut_callbacks[action] = [] self.registered_shortcut_callbacks[action].append(callback) self.shortcut_m...
You are a Python code generator, capable of creating scripts from specifications.
def remove_all_callbacks(self): """ Remove all callbacks registered to the shortcut manager :return: """ for action in self.registered_shortcut_callbacks.keys(): for callback in self.registered_shortcut_callbacks[action]: self.shortcut_manager.remove_c...
Can you write a function in Python 3 where it removes all callbacks registered to the shortcut manager.
As a python code expert, you are capable of creating scripts from specifications.
Determines if a point is left of a line in a line in a Knockout system.
Can you generate the documentation for the following Python 3 function def point_left_of_line(point, line_start, line_end): # determine sign of determinant # ((b.x - a.x)*(c.y - a.y) - (b.y - a.y)*(c.x - a.x)) > 0 return ((line_end[0] - line_start[0]) * (point[1] - line_start[1]) - (line_end[1] ...
You are a Python code generator, capable of creating scripts from specifications.
def point_on_line(point, line_start, line_end, accuracy=50.): """Checks whether a point lies on a line The function checks whether the point "point" (P) lies on the line defined by its starting point line_start (A) and its end point line_end (B). This is done by comparing the distance of [AB] with the ...
Can you implement a function in Python 3 that checks whether a point lies on a line in a
You are a Python code analyst, evaluating scripts for potential improvements.