sentence1
stringlengths
52
3.87M
sentence2
stringlengths
1
47.2k
label
stringclasses
1 value
def cal_dist_between_2_coord_frame_aligned_boxes(box1_pos, box1_size, box2_pos, box2_size): """ Calculate Euclidean distance between two boxes those edges are parallel to the coordinate axis The function decides condition based which corner to corner or edge to edge distance needs to be calculated. :param...
Calculate Euclidean distance between two boxes those edges are parallel to the coordinate axis The function decides condition based which corner to corner or edge to edge distance needs to be calculated. :param tuple box1_pos: x and y position of box 1 :param tuple box1_size: x and y size of box 1 :pa...
entailment
def mouse_click(self, widget, event=None): """Triggered when mouse click is pressed in the history tree. The method shows all scoped data for an execution step as tooltip or fold and unfold the tree by double-click and select respective state for double clicked element. """ if ev...
Triggered when mouse click is pressed in the history tree. The method shows all scoped data for an execution step as tooltip or fold and unfold the tree by double-click and select respective state for double clicked element.
entailment
def get_history_item_for_tree_iter(self, child_tree_iter): """Hands history item for tree iter and compensate if tree item is a dummy item :param Gtk.TreeIter child_tree_iter: Tree iter of row :rtype rafcon.core.execution.execution_history.HistoryItem: :return history tree item: ...
Hands history item for tree iter and compensate if tree item is a dummy item :param Gtk.TreeIter child_tree_iter: Tree iter of row :rtype rafcon.core.execution.execution_history.HistoryItem: :return history tree item:
entailment
def _store_expansion_state(self): """Iter recursively all tree items and store expansion state""" def store_tree_expansion(child_tree_iter, expansion_state): tree_item_path = self.history_tree_store.get_path(child_tree_iter) history_item = self.get_history_item_for_tree_iter(ch...
Iter recursively all tree items and store expansion state
entailment
def _restore_expansion_state(self): """Iter recursively all tree items and restore expansion state""" def restore_tree_expansion(child_tree_iter, expansion_state): tree_item_path = self.history_tree_store.get_path(child_tree_iter) history_item = self.get_history_item_for_tree_it...
Iter recursively all tree items and restore expansion state
entailment
def notification_selected_sm_changed(self, model, prop_name, info): """If a new state machine is selected, make sure expansion state is stored and tree updated""" selected_state_machine_id = self.model.selected_state_machine_id if selected_state_machine_id is None: return sel...
If a new state machine is selected, make sure expansion state is stored and tree updated
entailment
def notification_sm_changed(self, model, prop_name, info): """Remove references to non-existing state machines""" for state_machine_id in list(self._expansion_state.keys()): if state_machine_id not in self.model.state_machines: del self._expansion_state[state_machine_id]
Remove references to non-existing state machines
entailment
def execution_history_focus(self, model, prop_name, info): """ Arranges to put execution-history widget page to become top page in notebook when execution starts and stops and resets the boolean of modification_history_was_focused to False each time this notification are observed. """ if...
Arranges to put execution-history widget page to become top page in notebook when execution starts and stops and resets the boolean of modification_history_was_focused to False each time this notification are observed.
entailment
def clean_history(self, widget, event=None): """Triggered when the 'Clean History' button is clicked. Empties the execution history tree by adjusting the start index and updates tree store and view. """ self.history_tree_store.clear() selected_sm_m = self.model.get_selected_stat...
Triggered when the 'Clean History' button is clicked. Empties the execution history tree by adjusting the start index and updates tree store and view.
entailment
def update(self): """ rebuild the tree view of the history item tree store :return: """ # with self._update_lock: self._update_lock.acquire() self._store_expansion_state() self.history_tree_store.clear() selected_sm_m = self.model.get_selected_stat...
rebuild the tree view of the history item tree store :return:
entailment
def insert_history_item(self, parent, history_item, description, dummy=False): """Enters a single history item into the tree store :param Gtk.TreeItem parent: Parent tree item :param HistoryItem history_item: History item to be inserted :param str description: A description to be added ...
Enters a single history item into the tree store :param Gtk.TreeItem parent: Parent tree item :param HistoryItem history_item: History item to be inserted :param str description: A description to be added to the entry :param None dummy: Whether this is just a dummy entry (wrapper for co...
entailment
def insert_execution_history(self, parent, execution_history, is_root=False): """Insert a list of history items into a the tree store If there are concurrency history items, the method is called recursively. :param Gtk.TreeItem parent: the parent to add the next history item to :param ...
Insert a list of history items into a the tree store If there are concurrency history items, the method is called recursively. :param Gtk.TreeItem parent: the parent to add the next history item to :param ExecutionHistory execution_history: all history items of a certain state machine executio...
entailment
def insert_concurrent_execution_histories(self, parent, concurrent_execution_histories): """Adds the child execution histories of a concurrency state. :param Gtk.TreeItem parent: the parent to add the next history item to :param list[ExecutionHistory] concurrent_execution_histories: a list of a...
Adds the child execution histories of a concurrency state. :param Gtk.TreeItem parent: the parent to add the next history item to :param list[ExecutionHistory] concurrent_execution_histories: a list of all child execution histories :return:
entailment
def on_drag_data_get(self, widget, context, data, info, time): """dragged state is inserted and its state_id sent to the receiver :param widget: :param context: :param data: SelectionData: contains state_id :param info: :param time: """ library_state = se...
dragged state is inserted and its state_id sent to the receiver :param widget: :param context: :param data: SelectionData: contains state_id :param info: :param time:
entailment
def select_open_state_machine_of_selected_library_element(self): """Select respective state machine of selected library in state machine manager if already open """ (model, row_path) = self.view.get_selection().get_selected() if row_path: physical_library_path = model[row_path][self....
Select respective state machine of selected library in state machine manager if already open
entailment
def menu_item_remove_libraries_or_root_clicked(self, menu_item): """Removes library from hard drive after request second confirmation""" menu_item_text = self.get_menu_item_text(menu_item) logger.info("Delete item '{0}' pressed.".format(menu_item_text)) model, path = self.view.get_sele...
Removes library from hard drive after request second confirmation
entailment
def extract_library_properties_from_selected_row(self): """ Extracts properties library_os_path, library_path, library_name and tree_item_key from tree store row """ (model, row) = self.view.get_selection().get_selected() tree_item_key = model[row][self.ID_STORAGE_ID] library_item = mode...
Extracts properties library_os_path, library_path, library_name and tree_item_key from tree store row
entailment
def _get_selected_library_state(self): """Returns the LibraryState which was selected in the LibraryTree :return: selected state in TreeView :rtype: LibraryState """ library_os_path, library_path, library_name, item_key = self.extract_library_properties_from_selected_row() ...
Returns the LibraryState which was selected in the LibraryTree :return: selected state in TreeView :rtype: LibraryState
entailment
def start(self, execution_history, backward_execution=False, generate_run_id=True): """ Starts the execution of the state in a new thread. :return: """ self.execution_history = execution_history if generate_run_id: self._run_id = run_id_generator() self.backw...
Starts the execution of the state in a new thread. :return:
entailment
def join(self): """ Waits until the state finished execution. """ if self.thread: self.thread.join() self.thread = None else: logger.debug("Cannot join {0}, as the state hasn't been started, yet or is already finished!".format(self))
Waits until the state finished execution.
entailment
def setup_run(self): """ Executes a generic set of actions that has to be called in the run methods of each derived state class. :raises exceptions.TypeError: if the input or output data are not of type dict """ self.state_execution_status = StateExecutionStatus.ACTIVE self.pree...
Executes a generic set of actions that has to be called in the run methods of each derived state class. :raises exceptions.TypeError: if the input or output data are not of type dict
entailment
def recursively_preempt_states(self): """Preempt the state """ self.preempted = True self.paused = False self.started = False
Preempt the state
entailment
def get_default_input_values_for_state(self, state): """ Computes the default input values for a state :param State state: the state to get the default input values for """ from rafcon.core.states.library_state import LibraryState result_dict = {} for input_port_key, va...
Computes the default input values for a state :param State state: the state to get the default input values for
entailment
def create_output_dictionary_for_state(state): """Return empty output dictionary for a state :param state: the state of which the output data is determined :return: the output data of the target state """ from rafcon.core.states.library_state import LibraryState result_d...
Return empty output dictionary for a state :param state: the state of which the output data is determined :return: the output data of the target state
entailment
def add_input_data_port(self, name, data_type=None, default_value=None, data_port_id=None): """Add a new input data port to the state. :param str name: the name of the new input data port :param data_type: the type of the new output data port considered of class :class:`type` or ...
Add a new input data port to the state. :param str name: the name of the new input data port :param data_type: the type of the new output data port considered of class :class:`type` or :class:`str` which has to be convertible to :class:`type` :param default_value: the ...
entailment
def remove_input_data_port(self, data_port_id, force=False, destroy=True): """Remove an input data port from the state :param int data_port_id: the id or the output data port to remove :param bool force: if the removal should be forced without checking constraints :raises exceptions.Att...
Remove an input data port from the state :param int data_port_id: the id or the output data port to remove :param bool force: if the removal should be forced without checking constraints :raises exceptions.AttributeError: if the specified input data port does not exist
entailment
def remove_data_flows_with_data_port_id(self, data_port_id): """Remove all data flows whose from_key or to_key equals the passed data_port_id :param data_port_id: the id of a data_port of which all data_flows should be removed, the id can be a input or output data port id ...
Remove all data flows whose from_key or to_key equals the passed data_port_id :param data_port_id: the id of a data_port of which all data_flows should be removed, the id can be a input or output data port id
entailment
def add_output_data_port(self, name, data_type, default_value=None, data_port_id=None): """Add a new output data port to the state :param str name: the name of the new output data port :param data_type: the type of the new output data port considered of class :class:`type` or ...
Add a new output data port to the state :param str name: the name of the new output data port :param data_type: the type of the new output data port considered of class :class:`type` or :class:`str` which has to be convertible to :class:`type` :param default_value: the...
entailment
def remove_output_data_port(self, data_port_id, force=False, destroy=True): """Remove an output data port from the state :param int data_port_id: the id of the output data port to remove :raises exceptions.AttributeError: if the specified input data port does not exist """ if da...
Remove an output data port from the state :param int data_port_id: the id of the output data port to remove :raises exceptions.AttributeError: if the specified input data port does not exist
entailment
def get_io_data_port_id_from_name_and_type(self, name, data_port_type): """Returns the data_port_id of a data_port with a certain name and data port type :param name: the name of the target data_port :param data_port_type: the data port type of the target data port :return: the data por...
Returns the data_port_id of a data_port with a certain name and data port type :param name: the name of the target data_port :param data_port_type: the data port type of the target data port :return: the data port specified by the name and the type :raises exceptions.AttributeError: if ...
entailment
def get_data_port_by_id(self, data_port_id): """Search for the given data port id in the data ports of the state The method tries to find a data port in the input and output data ports. :param int data_port_id: the unique id of the data port :return: the data port with the searched id o...
Search for the given data port id in the data ports of the state The method tries to find a data port in the input and output data ports. :param int data_port_id: the unique id of the data port :return: the data port with the searched id or None if it is not found
entailment
def get_path(self, appendix=None, by_name=False): """ Recursively create the path of the state. The path is generated in bottom up method i.e. from the nested child states to the root state. The method concatenates either State.state_id (always unique) or State.name (maybe not unique but human ...
Recursively create the path of the state. The path is generated in bottom up method i.e. from the nested child states to the root state. The method concatenates either State.state_id (always unique) or State.name (maybe not unique but human readable) as state identifier for the path. :...
entailment
def get_storage_path(self, appendix=None): """ Recursively create the storage path of the state. The path is generated in bottom up method i.e. from the nested child states to the root state. The method concatenates the concatenation of (State.name and State.state_id) as state identifier for th...
Recursively create the storage path of the state. The path is generated in bottom up method i.e. from the nested child states to the root state. The method concatenates the concatenation of (State.name and State.state_id) as state identifier for the path. :param str appendix: the part of the p...
entailment
def get_state_machine(self): """Get a reference of the state_machine the state belongs to :rtype rafcon.core.state_machine.StateMachine :return: respective state machine """ if self.parent: if self.is_root_state: return self.parent else: ...
Get a reference of the state_machine the state belongs to :rtype rafcon.core.state_machine.StateMachine :return: respective state machine
entailment
def file_system_path(self, file_system_path): """Setter for file_system_path attribute of state :param str file_system_path: :return: """ if not isinstance(file_system_path, string_types): raise TypeError("file_system_path must be a string") self._file_system...
Setter for file_system_path attribute of state :param str file_system_path: :return:
entailment
def add_outcome(self, name, outcome_id=None): """Add a new outcome to the state :param str name: the name of the outcome to add :param int outcome_id: the optional outcome_id of the new outcome :return: outcome_id: the outcome if of the generated state :rtype: int """ ...
Add a new outcome to the state :param str name: the name of the outcome to add :param int outcome_id: the optional outcome_id of the new outcome :return: outcome_id: the outcome if of the generated state :rtype: int
entailment
def remove(self, state_element, recursive=True, force=False, destroy=True): """Remove item from state :param StateElement state_element: State element to be removed :param bool recursive: Only applies to removal of state and decides whether the removal should be called recursively o...
Remove item from state :param StateElement state_element: State element to be removed :param bool recursive: Only applies to removal of state and decides whether the removal should be called recursively on all child states :param bool force: if the removal should be forced without c...
entailment
def remove_outcome(self, outcome_id, force=False, destroy=True): """Remove an outcome from the state :param int outcome_id: the id of the outcome to remove :raises exceptions.AttributeError: if the specified outcome does not exist or equals the aborte...
Remove an outcome from the state :param int outcome_id: the id of the outcome to remove :raises exceptions.AttributeError: if the specified outcome does not exist or equals the aborted or preempted outcome
entailment
def check_child_validity(self, child): """Check validity of passed child object The method is called by state child objects (outcomes, data ports) when these are initialized or changed. The method checks the type of the child and then checks its validity in the context of the state. :p...
Check validity of passed child object The method is called by state child objects (outcomes, data ports) when these are initialized or changed. The method checks the type of the child and then checks its validity in the context of the state. :param object child: The child of the state that is ...
entailment
def _check_outcome_validity(self, check_outcome): """Checks the validity of an outcome Checks whether the id or the name of the outcome is already used by another outcome within the state. :param rafcon.core.logical_port.Outcome check_outcome: The outcome to be checked :return bool val...
Checks the validity of an outcome Checks whether the id or the name of the outcome is already used by another outcome within the state. :param rafcon.core.logical_port.Outcome check_outcome: The outcome to be checked :return bool validity, str message: validity is True, when the outcome is val...
entailment
def _check_data_port_validity(self, check_data_port): """Checks the validity of a data port Checks whether the data flows connected to the port do not conflict with the data types. :param rafcon.core.data_port.DataPort check_data_port: The data port to be checked :return bool validity,...
Checks the validity of a data port Checks whether the data flows connected to the port do not conflict with the data types. :param rafcon.core.data_port.DataPort check_data_port: The data port to be checked :return bool validity, str message: validity is True, when the data port is valid, Fals...
entailment
def _check_data_port_id(self, data_port): """Checks the validity of a data port id Checks whether the id of the given data port is already used by anther data port (input, output) within the state. :param rafcon.core.data_port.DataPort data_port: The data port to be checked :re...
Checks the validity of a data port id Checks whether the id of the given data port is already used by anther data port (input, output) within the state. :param rafcon.core.data_port.DataPort data_port: The data port to be checked :return bool validity, str message: validity is True, wh...
entailment
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 and output data ports. :param rafcon.core.data_port.Dat...
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 and output data ports. :param rafcon.core.data_port.DataPort data_port: The data port to be checked :r...
entailment
def check_input_data_type(self): """Check the input data types of the state Checks all input data ports if the handed data is not of the specified type and generate an error logger message with details of the found type conflict. """ for data_port in self.input_data_ports.values...
Check the input data types of the state Checks all input data ports if the handed data is not of the specified type and generate an error logger message with details of the found type conflict.
entailment
def check_output_data_type(self): """Check the output data types of the state Checks all output data ports if the handed data is not of the specified type and generate an error logger message with details of the found type conflict. """ for data_port in self.output_data_ports.va...
Check the output data types of the state Checks all output data ports if the handed data is not of the specified type and generate an error logger message with details of the found type conflict.
entailment
def change_state_id(self, state_id=None): """Changes the id of the state to a new id If no state_id is passed as parameter, a new state id is generated. :param str state_id: The new state id of the state :return: """ if state_id is None: state_id = state_id_...
Changes the id of the state to a new id If no state_id is passed as parameter, a new state id is generated. :param str state_id: The new state id of the state :return:
entailment
def get_semantic_data(self, path_as_list): """ Retrieves an entry of the semantic data. :param list path_as_list: The path in the vividict to retrieve the value from :return: """ target_dict = self.semantic_data for path_element in path_as_list: if path_eleme...
Retrieves an entry of the semantic data. :param list path_as_list: The path in the vividict to retrieve the value from :return:
entailment
def add_semantic_data(self, path_as_list, value, key): """ Adds a semantic data entry. :param list path_as_list: The path in the vividict to enter the value :param value: The value of the new entry. :param key: The key of the new entry. :return: """ assert isinst...
Adds a semantic data entry. :param list path_as_list: The path in the vividict to enter the value :param value: The value of the new entry. :param key: The key of the new entry. :return:
entailment
def remove_semantic_data(self, path_as_list): """ Removes a entry from the semantic data vividict. :param list path_as_list: The path of the vividict to delete. :return: removed value or dict """ if len(path_as_list) == 0: raise AttributeError("The argument path_as_l...
Removes a entry from the semantic data vividict. :param list path_as_list: The path of the vividict to delete. :return: removed value or dict
entailment
def destroy(self, recursive): """ Removes all the state elements. :param recursive: Flag wether to destroy all state elements which are removed """ for in_key in list(self.input_data_ports.keys()): self.remove_input_data_port(in_key, force=True, destroy=recursive) f...
Removes all the state elements. :param recursive: Flag wether to destroy all state elements which are removed
entailment
def input_data_ports(self, input_data_ports): """Property for the _input_data_ports field See Property. :param dict input_data_ports: Dictionary that maps :class:`int` data_port_ids onto values of type :class:`rafcon.core.state_elements.data_port.InputData...
Property for the _input_data_ports field See Property. :param dict input_data_ports: Dictionary that maps :class:`int` data_port_ids onto values of type :class:`rafcon.core.state_elements.data_port.InputDataPort` :raises exceptions.TypeError: if the input_...
entailment
def output_data_ports(self, output_data_ports): """ Setter for _output_data_ports field See property :param dict output_data_ports: Dictionary that maps :class:`int` data_port_ids onto values of type :class:`rafcon.core.state_elements.data_port.OutputDataP...
Setter for _output_data_ports field See property :param dict output_data_ports: Dictionary that maps :class:`int` data_port_ids onto values of type :class:`rafcon.core.state_elements.data_port.OutputDataPort` :raises exceptions.TypeError: if the output_dat...
entailment
def income(self, income): """Setter for the state's income""" if not isinstance(income, Income): raise ValueError("income must be of type Income") old_income = self.income self._income = income try: income.parent = self except ValueError: ...
Setter for the state's income
entailment
def outcomes(self, outcomes): """ Setter for _outcomes field See property. :param dict outcomes: Dictionary outcomes[outcome_id] that maps :class:`int` outcome_ids onto values of type :class:`rafcon.core.state_elements.logical_port.Outcome` :raises excepti...
Setter for _outcomes field See property. :param dict outcomes: Dictionary outcomes[outcome_id] that maps :class:`int` outcome_ids onto values of type :class:`rafcon.core.state_elements.logical_port.Outcome` :raises exceptions.TypeError: if outcomes parameter has t...
entailment
def is_root_state_of_library(self): """ If self is the attribute LibraryState.state_copy of a LibraryState its the library root state and its parent is a LibraryState :return True or False :rtype bool """ from rafcon.core.states.library_state import LibraryState r...
If self is the attribute LibraryState.state_copy of a LibraryState its the library root state and its parent is a LibraryState :return True or False :rtype bool
entailment
def get_next_upper_library_root_state(self): """ Get next upper library root state The method recursively checks state parent states till finding a StateMachine as parent or a library root state. If self is a LibraryState the next upper library root state is searched and it is not handed self.s...
Get next upper library root state The method recursively checks state parent states till finding a StateMachine as parent or a library root state. If self is a LibraryState the next upper library root state is searched and it is not handed self.state_copy. :return library root state (Execution...
entailment
def get_uppermost_library_root_state(self): """Find state_copy of uppermost LibraryState Method checks if there is a parent library root state and assigns it to be the current library root state till there is no further parent library root state. """ library_root_state = self.g...
Find state_copy of uppermost LibraryState Method checks if there is a parent library root state and assigns it to be the current library root state till there is no further parent library root state.
entailment
def finalize(self, outcome=None): """Finalize state This method is called when the run method finishes :param rafcon.core.logical_port.Outcome outcome: final outcome of the state :return: Nothing for the moment """ # Set the final outcome of the state if outcom...
Finalize state This method is called when the run method finishes :param rafcon.core.logical_port.Outcome outcome: final outcome of the state :return: Nothing for the moment
entailment
def cluster_on_extra_high_voltage(network, busmap, with_time=True): """ Main function of the EHV-Clustering approach. Creates a new clustered pypsa.Network given a busmap mapping all bus_ids to other bus_ids of the same network. Parameters ---------- network : pypsa.Network Container fo...
Main function of the EHV-Clustering approach. Creates a new clustered pypsa.Network given a busmap mapping all bus_ids to other bus_ids of the same network. Parameters ---------- network : pypsa.Network Container for all network components. busmap : dict Maps old bus_ids to new...
entailment
def graph_from_edges(edges): """ Constructs an undirected multigraph from a list containing data on weighted edges. Parameters ---------- edges : list List of tuples each containing first node, second node, weight, key. Returns ------- M : :class:`networkx.classes.multigraph.Mu...
Constructs an undirected multigraph from a list containing data on weighted edges. Parameters ---------- edges : list List of tuples each containing first node, second node, weight, key. Returns ------- M : :class:`networkx.classes.multigraph.MultiGraph
entailment
def gen(nodes, n, graph): # TODO There could be a more convenient way of doing this. This generators # single purpose is to prepare data for multiprocessing's starmap function. """ Generator for applying multiprocessing. Parameters ---------- nodes : list List of nodes in the system. ...
Generator for applying multiprocessing. Parameters ---------- nodes : list List of nodes in the system. n : int Number of desired multiprocessing units. graph : :class:`networkx.classes.multigraph.MultiGraph Graph representation of an electrical grid. Returns ----...
entailment
def busmap_from_psql(network, session, scn_name): """ Retrieves busmap from `model_draft.ego_grid_pf_hv_busmap` on the <OpenEnergyPlatform>[www.openenergy-platform.org] by a given scenario name. If this busmap does not exist, it is created with default values. Parameters ---------- network : py...
Retrieves busmap from `model_draft.ego_grid_pf_hv_busmap` on the <OpenEnergyPlatform>[www.openenergy-platform.org] by a given scenario name. If this busmap does not exist, it is created with default values. Parameters ---------- network : pypsa.Network object Container for all network compo...
entailment
def kmean_clustering(network, n_clusters=10, load_cluster=False, line_length_factor=1.25, remove_stubs=False, use_reduced_coordinates=False, bus_weight_tocsv=None, bus_weight_fromcsv=None, n_init=10, max_iter=300, tol=1e-4, ...
Main function of the k-mean clustering approach. Maps an original network to a new one with adjustable number of nodes and new coordinates. Parameters ---------- network : :class:`pypsa.Network Container for all network components. n_clusters : int Desired number of clusters. ...
entailment
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. """ super(DescriptionEditorController...
Register callback methods for triggered actions :param rafcon.gui.shortcut_manager.ShortcutManager shortcut_manager: Shortcut Manager Object holding mappings between shortcuts and actions.
entailment
def register_view(self, view): """Called when the View was registered""" super(GraphicalEditorController, self).register_view(view) self.view.connect('meta_data_changed', self._meta_data_changed) self.focus_changed_handler_id = self.view.editor.connect('focus-changed', self._move_focuse...
Called when the View was registered
entailment
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. """ shortcut_manager.add_callback_for...
Register callback methods for triggered actions :param rafcon.gui.shortcut_manager.ShortcutManager shortcut_manager: Shortcut Manager Object holding mappings between shortcuts and actions.
entailment
def on_config_value_changed(self, config_m, prop_name, info): """Callback when a config value has been changed :param ConfigModel config_m: The config model that has been changed :param str prop_name: Should always be 'config' :param dict info: Information e.g. about the changed config ...
Callback when a config value has been changed :param ConfigModel config_m: The config model that has been changed :param str prop_name: Should always be 'config' :param dict info: Information e.g. about the changed config key
entailment
def on_drag_data_received(self, widget, context, x, y, data, info, time): """Receives state_id from LibraryTree and moves the state to the position of the mouse :param widget: :param context: :param x: Integer: x-position of mouse :param y: Integer: y-position of mouse :...
Receives state_id from LibraryTree and moves the state to the position of the mouse :param widget: :param context: :param x: Integer: x-position of mouse :param y: Integer: y-position of mouse :param data: SelectionData: contains state_id :param info: :param time...
entailment
def on_drag_motion(self, widget, context, x, y, time): """Changes the selection on mouse over during drag motion :param widget: :param context: :param x: Integer: x-position of mouse :param y: Integer: y-position of mouse :param time: """ hovered_item = I...
Changes the selection on mouse over during drag motion :param widget: :param context: :param x: Integer: x-position of mouse :param y: Integer: y-position of mouse :param time:
entailment
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 graphical editor is in focus. """ if react_to_event(self.view, self.view.editor, event): sta...
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 graphical editor is in focus.
entailment
def _copy_selection(self, *event): """Copies the current selection to the clipboard. """ if react_to_event(self.view, self.view.editor, event): logger.debug("copy selection") global_clipboard.copy(self.model.selection) return True
Copies the current selection to the clipboard.
entailment
def _cut_selection(self, *event): """Cuts the current selection and copys it to the clipboard. """ if react_to_event(self.view, self.view.editor, event): logger.debug("cut selection") global_clipboard.cut(self.model.selection) return True
Cuts the current selection and copys it to the clipboard.
entailment
def _paste_clipboard(self, *event): """Paste the current clipboard into the current selection if the current selection is a container state. """ if react_to_event(self.view, self.view.editor, event): logger.debug("Paste") gui_helper_state_machine.paste_into_selected_state...
Paste the current clipboard into the current selection if the current selection is a container state.
entailment
def _move_focused_item_into_viewport(self, view, focused_item): """Called when an item is focused, moves the item into the viewport :param view: :param StateView | ConnectionView | PortView focused_item: The focused item """ self.view.editor.handler_block(self.drag_motion_handle...
Called when an item is focused, moves the item into the viewport :param view: :param StateView | ConnectionView | PortView focused_item: The focused item
entailment
def move_item_into_viewport(self, item): """Causes the `item` to be moved into the viewport The zoom factor and the position of the viewport are updated to move the `item` into the viewport. If `item` is not a `StateView`, the parental `StateView` is moved into the viewport. :param Sta...
Causes the `item` to be moved into the viewport The zoom factor and the position of the viewport are updated to move the `item` into the viewport. If `item` is not a `StateView`, the parental `StateView` is moved into the viewport. :param StateView | ConnectionView | PortView item: The item to...
entailment
def state_machine_destruction(self, model, prop_name, info): """ Clean up when state machine is being destructed """ if self.model is model: # only used for the state machine destruction case self.canvas.get_view_for_model(self.root_state_m).remove()
Clean up when state machine is being destructed
entailment
def meta_changed_notify_after(self, state_machine_m, _, info): """Handle notification about the change of a state's meta data The meta data of the affected state(s) are read and the view updated accordingly. :param StateMachineModel state_machine_m: Always the state machine model belonging to t...
Handle notification about the change of a state's meta data The meta data of the affected state(s) are read and the view updated accordingly. :param StateMachineModel state_machine_m: Always the state machine model belonging to this editor :param str _: Always "state_meta_signal" :param...
entailment
def state_machine_change_after(self, model, prop_name, info): """Called on any change within th state machine This method is called, when any state, transition, data flow, etc. within the state machine changes. This then typically requires a redraw of the graphical editor, to display these chan...
Called on any change within th state machine This method is called, when any state, transition, data flow, etc. within the state machine changes. This then typically requires a redraw of the graphical editor, to display these changes immediately. :param rafcon.gui.models.state_machine.StateMac...
entailment
def set_focus_to_state_model(self, state_m, ratio_requested=0.8): """ Focus a state view of respective state model :param rafcon.gui.model.state state_m: Respective state model of state view to be focused :param ratio_requested: Minimum ratio of the screen which is requested, so can be more ...
Focus a state view of respective state model :param rafcon.gui.model.state state_m: Respective state model of state view to be focused :param ratio_requested: Minimum ratio of the screen which is requested, so can be more :return:
entailment
def add_state_view_for_model(self, state_m, parent_v=None, rel_pos=(0, 0), size=(100, 100), hierarchy_level=1): """Creates a `StateView` (recursively) and adds it to the canvas The method uses the `StateModel` `state_m` to create the according `StateView`. For all content within `state_m`, suc...
Creates a `StateView` (recursively) and adds it to the canvas The method uses the `StateModel` `state_m` to create the according `StateView`. For all content within `state_m`, such as connections, states and ports, the views are also created. All views are added to the canvas. :param rafcon.g...
entailment
def add_transition_view_for_model(self, transition_m, parent_state_m): """Creates a `TransitionView` and adds it to the canvas The method creates a`TransitionView` from the given `TransitionModel `transition_m` and adds it to the canvas. :param TransitionModel transition_m: The transition for ...
Creates a `TransitionView` and adds it to the canvas The method creates a`TransitionView` from the given `TransitionModel `transition_m` and adds it to the canvas. :param TransitionModel transition_m: The transition for which a view is to be created :param ContainerStateModel parent_state_m: ...
entailment
def add_data_flow_view_for_model(self, data_flow_m, parent_state_m): """Creates a `DataFlowView` and adds it to the canvas The method creates a`DataFlowView` from the given `DataFlowModel `data_flow_m` and adds it to the canvas. :param DataFlowModel data_flow_m: The data flow for which a view ...
Creates a `DataFlowView` and adds it to the canvas The method creates a`DataFlowView` from the given `DataFlowModel `data_flow_m` and adds it to the canvas. :param DataFlowModel data_flow_m: The data flow for which a view is to be created :param ContainerStateModel parent_state_m: The parenta...
entailment
def react_to_event(self, event): """Check whether the given event should be handled Checks, whether the editor widget has the focus and whether the selected state machine corresponds to the state machine of this editor. :param event: GTK event object :return: True if the event ...
Check whether the given event should be handled Checks, whether the editor widget has the focus and whether the selected state machine corresponds to the state machine of this editor. :param event: GTK event object :return: True if the event should be handled, else False :rtype...
entailment
async def initialize(bot: Bot, host, password, rest_port, ws_port, timeout=30): """ Initializes the websocket connection to the lavalink player. .. important:: This function must only be called AFTER the bot has received its "on_ready" event! Parameters ---------- bot : Bot ...
Initializes the websocket connection to the lavalink player. .. important:: This function must only be called AFTER the bot has received its "on_ready" event! Parameters ---------- bot : Bot An instance of a discord.py `Bot` object. host : str The hostname or IP ad...
entailment
async def connect(channel: discord.VoiceChannel): """ Connects to a discord voice channel. This is the publicly exposed way to connect to a discord voice channel. The :py:func:`initialize` function must be called first! Parameters ---------- channel Returns ------- Player ...
Connects to a discord voice channel. This is the publicly exposed way to connect to a discord voice channel. The :py:func:`initialize` function must be called first! Parameters ---------- channel Returns ------- Player The created Player object. Raises ------ Inde...
entailment
def register_event_listener(coro): """ Registers a coroutine to receive lavalink event information. This coroutine will accept three arguments: :py:class:`Player`, :py:class:`LavalinkEvents`, and possibly an extra. The value of the extra depends on the value of the second argument. If the seco...
Registers a coroutine to receive lavalink event information. This coroutine will accept three arguments: :py:class:`Player`, :py:class:`LavalinkEvents`, and possibly an extra. The value of the extra depends on the value of the second argument. If the second argument is :py:attr:`LavalinkEvents.TRACK_E...
entailment
def register_update_listener(coro): """ Registers a coroutine to receive lavalink player update information. This coroutine will accept a two arguments: an instance of :py:class:`Player` and an instance of :py:class:`PlayerState`. Parameters ---------- coro Raises ------ TypeE...
Registers a coroutine to receive lavalink player update information. This coroutine will accept a two arguments: an instance of :py:class:`Player` and an instance of :py:class:`PlayerState`. Parameters ---------- coro Raises ------ TypeError If ``coro`` is not a coroutine.
entailment
def register_stats_listener(coro): """ Registers a coroutine to receive lavalink server stats information. This coroutine will accept a single argument which will be an instance of :py:class:`Stats`. Parameters ---------- coro Raises ------ TypeError If ``coro`` is not...
Registers a coroutine to receive lavalink server stats information. This coroutine will accept a single argument which will be an instance of :py:class:`Stats`. Parameters ---------- coro Raises ------ TypeError If ``coro`` is not a coroutine.
entailment
def prepare_destruction(self): """Get rid of circular references""" self._tool = None self._painter = None self.relieve_model(self._selection) self._selection = None # clear observer class attributes, also see ExtendenController.destroy() self._Observer__PROP_TO_M...
Get rid of circular references
entailment
def get_port_at_point(self, vpos, distance=10, exclude=None, exclude_port_fun=None): """ Find item with port closest to specified position. List of items to be ignored can be specified with `exclude` parameter. Tuple is returned - found item - closest, connecta...
Find item with port closest to specified position. List of items to be ignored can be specified with `exclude` parameter. Tuple is returned - found item - closest, connectable port - closest point on found port (in view coordinates) :Parameters: vpos ...
entailment
def get_item_at_point_exclude(self, pos, selected=True, exclude=None): """ Return the topmost item located at ``pos`` (x, y). Parameters: - selected: if False returns first non-selected item - exclude: if specified don't check for these items """ items = self._...
Return the topmost item located at ``pos`` (x, y). Parameters: - selected: if False returns first non-selected item - exclude: if specified don't check for these items
entailment
def queue_draw_item(self, *items): """Extends the base class method to allow Ports to be passed as item :param items: Items that are to be redrawn """ gaphas_items = [] for item in items: if isinstance(item, Element): gaphas_items.append(item) ...
Extends the base class method to allow Ports to be passed as item :param items: Items that are to be redrawn
entailment
def get_items_at_point(self, pos, selected=True, distance=0): """ Return the items located at ``pos`` (x, y). :param bool selected: if False returns first non-selected item :param float distance: Maximum distance to be considered as "at point" (in viewport pixel) """ items = s...
Return the items located at ``pos`` (x, y). :param bool selected: if False returns first non-selected item :param float distance: Maximum distance to be considered as "at point" (in viewport pixel)
entailment
def select_item(self, items): """ Select an items. This adds `items` to the set of selected items. """ if not items: return elif not hasattr(items, "__iter__"): items = (items,) selection_changed = False with self._suppress_selection_events(): ...
Select an items. This adds `items` to the set of selected items.
entailment
def unselect_item(self, item): """ Unselect an item. """ self.queue_draw_item(item) if item.model in self._selection: with self._suppress_selection_events(): self._selection.remove(item.model) self.emit('selection-changed', self._get_selected_items())
Unselect an item.
entailment
def unselect_all(self): """ Clearing the selected_item also clears the focused_item. """ items = self._get_selected_items() with self._suppress_selection_events(): self._selection.clear() self.queue_draw_item(*items) self.emit('selection-changed', self._get_selected_i...
Clearing the selected_item also clears the focused_item.
entailment
def _get_selected_items(self): """ Return an Item (e.g. StateView) for each model (e.g. StateModel) in the current selection """ return set(self.canvas.get_view_for_model(model) for model in self._selection)
Return an Item (e.g. StateView) for each model (e.g. StateModel) in the current selection
entailment
def handle_new_selection(self, items): """ Determines the selection The selection is based on the previous selection, the currently pressed keys and the passes newly selected items :param items: The newly selected item(s) """ if items is None: items = () eli...
Determines the selection The selection is based on the previous selection, the currently pressed keys and the passes newly selected items :param items: The newly selected item(s)
entailment
def _get_focused_item(self): """ Returns the currently focused item """ focused_model = self._selection.focus if not focused_model: return None return self.canvas.get_view_for_model(focused_model)
Returns the currently focused item
entailment
def _set_focused_item(self, item): """ Sets the focus to the passed item""" if not item: return self._del_focused_item() if item.model is not self._selection.focus: self.queue_draw_item(self._focused_item, item) self._selection.focus = item.model ...
Sets the focus to the passed item
entailment