output
stringlengths
1
928k
instruction
stringlengths
7
928k
system
stringlengths
0
104k
Solve each cluster into separate units and try to optimize them separately
How would you explain what the following Python 3 function does def solve(self, scenario, solver): clusters = set(self.clustering.busmap.values) n = len(clusters) self.stats = {'clusters': pd.DataFrame( index=sorted(clusters), columns=["decompose", "spread", "transfer"])}...
As a Python code translator, you convert algorithms and pseudocode into Python.
Modify the state of the transition origin at the same time.
Make a summary of the following Python 3 code def modify_origin(self, from_state, from_outcome): if not (from_state is None and from_outcome is None): if not isinstance(from_state, string_types): raise ValueError("Invalid transition origin port: from_state must be a string") ...
You are a Python code analyst, evaluating scripts for potential improvements.
Modify the target state and outcome of a transition.
Explain what the following Python 3 code does def modify_target(self, to_state, to_outcome=None): if not (to_state is None and (to_outcome is not int and to_outcome is not None)): if not isinstance(to_state, string_types): raise ValueError("Invalid transition target port: to_state mu...
You are a Python code analyst, evaluating scripts for potential improvements.
def register_view(self, view): """Called when the View was registered""" ExtendedController.register_view(self, view) # no super to avoid sm based selection initialization view['name_text'].set_property('editable', True) view['value_text'].set_property('editable', True) view['ty...
Write a Python 3 function for calling when the view was registered
As a python code expert, you are capable of creating scripts from specifications.
Check whether global variable is editable
Can you generate a brief explanation for the following Python 3 code def global_variable_is_editable(self, gv_name, intro_message='edit'): if self.model.global_variable_manager.is_locked(gv_name): logger.error("{1} of global variable '{0}' is not possible, as it is locked".format(gv_name, intro_mess...
As a Python code composer, you craft elegant and concise scripts.
def on_add(self, widget, data=None): """Create a global variable with default value and select its row Triggered when the add button in the global variables tab is clicked. """ gv_name = "new_global_%s" % self.global_variable_counter self.global_variable_counter += 1 try...
Implement a Python 3 function for triggering when the add button is clicked.
You are a Python code generator, capable of creating scripts from specifications.
Locks respective selected core element
Can you generate a brief explanation for the following Python 3 code def on_lock(self, widget, data=None): path_list = None if self.view is not None: model, path_list = self.tree_view.get_selection().get_selected_rows() models = [self.list_store[path][self.MODEL_STORAGE_ID] for path ...
As a python code expert, you are capable of creating scripts from specifications.
def remove_core_element(self, model): """Remove respective core element of handed global variable name :param str model: String that is the key/gv_name of core element which should be removed :return: """ gv_name = model if self.global_variable_is_editable(gv_name, "Dele...
Implement a function in Python 3 to remove the respective core element of handed global variable name
As a Python code composer, you craft elegant and concise scripts.
def apply_new_global_variable_name(self, path, new_gv_name): """Change global variable name/key according handed string Updates the global variable name only if different and already in list store. :param path: The path identifying the edited global variable tree view row, can be str, int or t...
Implement a function in Python 3 to apply the new global variable name according handed string
As a Python code translator, you convert algorithms and pseudocode into Python.
def apply_new_global_variable_value(self, path, new_value_as_string): """Change global variable value according handed string Updates the global variable value only if new value string is different to old representation. :param path: The path identifying the edited global variable tree view ro...
Write a Python 3 script to apply the new value according handed string to the global variable tree view row.
You are a Python code analyst, evaluating scripts for potential improvements.
Applies the new data type according handed string to the global variable tree view row.
Can you generate the documentation for the following Python 3 function def apply_new_global_variable_type(self, path, new_data_type_as_string): if self.list_store[path][self.DATA_TYPE_AS_STRING_STORAGE_ID] == new_data_type_as_string: return gv_name = self.list_store[path][self.NAME_STORAGE_I...
You are a Python code architect, reviewing and designing scalable and efficient code
def assign_notification_from_gvm(self, model, prop_name, info): """Handles gtkmvc3 notification from global variable manager Calls update of whole list store in case new variable was added. Avoids to run updates without reasonable change. Holds tree store and updates row elements if is-locked o...
Write a Python 3 function that can handle GTKMVC3 notification from global variable manager
You are a Python code architect, reviewing and designing scalable and efficient code
def update_global_variables_list_store(self): """Updates the global variable list store Triggered after creation or deletion of a variable has taken place. """ # logger.info("update") self.list_store_iterators = {} self.list_store.clear() keys = self.model.global...
How would you code a function in Python 3 to update the global variable list store with the current values of all global variables.
You are a Python code generator, capable of creating scripts from specifications.
This function resaves all libraries found at the spcified path
Here you have a function in Python 3, explain what it does def convert_libraries_in_path(config_path, lib_path, target_path=None): for lib in os.listdir(lib_path): if os.path.isdir(os.path.join(lib_path, lib)) and not '.' == lib[0]: if os.path.exists(os.path.join(os.path.join(lib_path, lib), "st...
As a Python code composer, you craft elegant and concise scripts.
Searches and returns the View for the given id and type
Explain what the following Python 3 code does def get_view_for_id(self, view_class, element_id, parent_item=None): from rafcon.gui.mygaphas.items.state import StateView from rafcon.gui.mygaphas.items.connection import DataFlowView, TransitionView if parent_item is None: items = self....
You are a Python code generator, capable of creating scripts from specifications.
def wait_for_update(self, trigger_update=False): """Update canvas and handle all events in the gtk queue :param bool trigger_update: Whether to call update_now() or not """ if trigger_update: self.update_now() from gi.repository import Gtk from gi.repository...
Can you create a Python 3 function that updates canvas and handle all events in the gtk queue
As a Python code analyst, you investigate and solve complex coding mysteries
def _get_value(self): """ Return two delegating variables. Each variable should contain a value attribute with the real value. """ x, y = self._point.x, self._point.y self._px, self._py = self._item_point.canvas.get_matrix_i2i(self._item_point, ...
How would you code a function in Python 3 to return two delegating variables. Each variable should contain a value attribute with the real value. Each variable should contain a value attribute with the real value. Each variable should contain a value attribute with the real value.
As a Python code translator, you convert algorithms and pseudocode into Python.
def convert_string_to_type(string_value): """Converts a string into a type or class :param string_value: the string to be converted, e.g. "int" :return: The type derived from string_value, e.g. int """ # If the parameter is already a type, return it if string_value in ['None', type(None).__name...
Create a Python 3 function to convert a string into a type or class.
As a Python code analyst, you investigate and solve complex coding mysteries
Checks whether inheriting_type inherits from base_type.
Make a summary of the following Python 3 code def type_inherits_of_type(inheriting_type, base_type): assert isinstance(inheriting_type, type) or isclass(inheriting_type) assert isinstance(base_type, type) or isclass(base_type) if inheriting_type == base_type: return True else: if len(in...
You are a Python code generator, capable of creating scripts from specifications.
This function deletes all the tables in the database.
How would you explain what the following Python 3 function does def clear_results_db(session): '''Used to clear the result tables in the OEDB. Caution! This deletes EVERY RESULT SET!''' from egoio.db_tables.model_draft import EgoGridPfHvResultBus as BusResult,\ EgoGridPfHvResultBusT as BusTResu...
You are a Python code analyst, evaluating scripts for potential improvements.
Return results obtained from PyPSA to Oedb
Explain what the following Python 3 code does def results_to_oedb(session, network, args, grid='hv', safe_results=False): # Update generator_ids when k_means clustering to get integer ids if args['network_clustering_kmeans'] != False: new_index=pd.DataFrame(index = network.generators.index) new_...
As a Python code translator, you convert algorithms and pseudocode into Python.
This function runs the sql script in the folder sql_scripts
Can you generate the documentation for the following Python 3 function def run_sql_script(conn, scriptname='results_md2grid.sql'): script_dir = os.path.abspath( os.path.join(os.path.dirname(__file__), 'sql_scripts')) script_str = open(os.path.join(script_dir, scriptname)).read() conn.execution_opti...
As a Python code composer, you craft elegant and concise scripts.
Function that adds an additional network to the existing network container.
Can you generate a brief explanation for the following Python 3 code def extension (network, session, version, scn_extension, start_snapshot, end_snapshot, **kwargs): """ Function that adds an additional network to the existing network container. The new network can include every PyPSA-comp...
You are a Python code analyst, evaluating scripts for potential improvements.
def decommissioning(network, session, args, **kwargs): """ Function that removes components in a decommissioning-scenario from the existing network container. Currently, only lines can be decommissioned. All components of the decommissioning scenario need to be inserted in the fi...
Create a Python 3 function to function that removes components in a decommissioning scenario from the network container.
You are a Python code analyst, evaluating scripts for potential improvements.
Function that calculates the square of the distance between two points.
Can you generate the documentation for the following Python 3 function def distance(x0, x1, y0, y1): # Calculate square of the distance between two points (Pythagoras) distance = (x1.values- x0.values)*(x1.values- x0.values)\ + (y1.values- y0.values)*(y1.values- y0.values) return distance
As a Python code composer, you craft elegant and concise scripts.
Function that finds the geographical nearest point in a network from a given bus.
Can you generate a brief explanation for the following Python 3 code def calc_nearest_point(bus1, network): bus1_index = network.buses.index[network.buses.index == bus1] forbidden_buses = np.append( bus1_index.values, network.lines.bus1[ network.lines.bus0 == bus1].values) forbidd...
You are a Python code generator, capable of creating scripts from specifications.
Populate the _mapped attribute with orm class name.
Here you have a function in Python 3, explain what it does def map_ormclass(self, name): try: self._mapped[name] = getattr(self._pkg, self._prefix + name) except AttributeError: print('Warning: Relation %s does not exist.' % name)
You are a Python code analyst, evaluating scripts for potential improvements.
def configure_timeindex(self): """ Construct a DateTimeIndex with the queried temporal resolution, start- and end_snapshot. """ try: ormclass = self._mapped['TempResolution'] if self.version: tr = self.session.query(ormclass).filter( ...
Write a Python 3 function that can construct a DatetimeIndex with the queried temporal resolution start - and end - snapshot.
As a Python code analyst, you investigate and solve complex coding mysteries
def fetch_by_relname(self, name): """ Construct DataFrame with component data from filtered table data. Parameters ---------- name : str Component name. Returns ------- pd.DataFrame Component data. """ ormclass = self._ma...
Can you implement a function in Python 3 that fetches DataFrame with component data from filtered table data.
As a Python code analyst, you investigate and solve complex coding mysteries
def series_fetch_by_relname(self, name, column): """ Construct DataFrame with component timeseries data from filtered table data. Parameters ---------- name : str Component name. column : str Component field with timevarying data. Returns...
Write a Python 3 script to fetch series data from filtered by component name and column.
As a Python code translator, you convert algorithms and pseudocode into Python.
Build a PyPSA Network object.
How would you explain what the following Python 3 function does def build_network(self, network=None, *args, **kwargs): # TODO: build_network takes care of divergences in database design and # future PyPSA changes from PyPSA's v0.6 on. This concept should be # replaced, when the oedb has a revis...
You are a Python code generator, capable of creating scripts from specifications.
This method starts the concurrency state execution process
Make a summary of the following Python 3 code def run(self): logger.debug("Starting execution of {0}{1}".format(self, " (backwards)" if self.backward_execution else "")) self.setup_run() try: concurrency_history_item = self.setup_forward_or_backward_execution() concurren...
As a Python code translator, you convert algorithms and pseudocode into Python.
Check validity of a transition of BarrierConcurrencyState.
Can you tell what is the following Python 3 function doing def _check_transition_validity(self, check_transition): valid, message = super(PreemptiveConcurrencyState, self)._check_transition_validity(check_transition) if not valid: return False, message # Only transitions to the pare...
As a Python code analyst, you investigate and solve complex coding mysteries
def prepare_destruction(self): """Prepares the model for destruction Un-registers itself as observer from the state machine and the root state """ try: self.relieve_model(self.state_machine_model) assert self.__buffered_root_state_model is self.state_machine_mode...
How would you implement a function in Python 3 that prepares the model for destruction Unregisters itself from the state machine and the root state machine and the modification history.
As a Python code analyst, you investigate and solve complex coding mysteries
def recover_specific_version(self, pointer_on_version_to_recover): """ Recovers a specific version of the all_time_history element by doing several undos and redos. :param pointer_on_version_to_recover: the id of the list element which is to recover :return: """ # search for tra...
Implement a function in Python 3 to recover a specific version of the all_time_history element by doing several undos and redos.
You are a Python code architect, reviewing and designing scalable and efficient code
def get_undo_redo_list_from_active_trail_history_item_to_version_id(self, version_id): """Perform fast search from currently active branch to specific version_id and collect all recovery steps. """ all_trail_action = [a.version_id for a in self.single_trail_history() if a is not None] al...
Write a Python 3 script to perform fast search from currently active branch to specific version_id and collect all recovery steps.
You are a Python code generator, capable of creating scripts from specifications.
def set_pane_position(self, config_id): """Adjusts the position of a GTK Pane to a value stored in the runtime config file. If there was no value stored, the pane's position is set to a default value. :param config_id: The pane identifier saved in the runtime config file """ def...
Implement a Python 3 function for adjusting the position of a GTK Pane to a value stored in the runtime config file.
As a Python code analyst, you investigate and solve complex coding mysteries
def model_changed(self, model, prop_name, info): """ Highlight buttons according actual execution status. Furthermore it triggers the label redraw of the active state machine. """ # TODO: find nice solution # this in only required if the GUI is terminated via Ctrl+C signal ...
Implement a Python 3 function for highlighting buttons according actual execution status.
As a Python code translator, you convert algorithms and pseudocode into Python.
def focus_notebook_page_of_controller(self, controller): """Puts the focus on the given child controller The method implements focus request of the notebooks in left side-bar of the main window. Thereby it is the master-function of focus pattern of the notebooks in left side-bar. Actua...
Write a Python 3 script to put the focus on the given child controller.
As a Python code composer, you craft elegant and concise scripts.
def on_notebook_tab_switch(self, notebook, page, page_num, title_label, window, notebook_identifier): """Triggered whenever a left-bar notebook tab is changed. Updates the title of the corresponding notebook and updates the title of the left-bar window in case un-docked. :param notebook: The G...
Write a Python 3 script to trigger whenever a left - bar notebook tab is changed.
You are a Python code analyst, evaluating scripts for potential improvements.
Updates the currently pressed keys
Can you tell what is the following Python 3 function doing def _on_key_press(self, widget, event): self.currently_pressed_keys.add(event.keyval) if event.keyval in [Gdk.KEY_Tab, Gdk.KEY_ISO_Left_Tab] and event.state & Gdk.ModifierType.CONTROL_MASK: self.toggle_sidebars()
As a Python code translator, you convert algorithms and pseudocode into Python.
def prepare_destruction(self): """Saves current configuration of windows and panes to the runtime config file, before RAFCON is closed.""" plugins.run_hook("pre_destruction") logger.debug("Saving runtime config to {0}".format(global_runtime_config.config_file_path)) # store pane last p...
Implement a function in Python 3 to save the current configuration of windows panes and state machines to the runtime config file before RAFCON is closed.
As a Python code translator, you convert algorithms and pseudocode into Python.
Sets up the execution of the concurrency states dependent on if the state is executed forward of backward.
Can you generate a brief explanation for the following Python 3 code def setup_forward_or_backward_execution(self): if self.backward_execution: # pop the return item of this concurrency state to get the correct scoped data last_history_item = self.execution_history.pop_last_item() ...
As a python code expert, you are capable of creating scripts from specifications.
This function is called by the concurrency state machine when the concurrency state is complete.
Explain what the following Python 3 code does def finalize_concurrency_state(self, outcome): final_outcome = outcome self.write_output_data() self.check_output_data_type() self.execution_history.push_return_history_item(self, CallType.CONTAINER, self, self.output_data) self.state...
As a Python code translator, you convert algorithms and pseudocode into Python.
Return the length of the head of the port.
Given the following Python 3 function, write the documentation def _head_length(self, port): if not port: return 0. parent_state_v = self.get_parent_state_v() if parent_state_v is port.parent: # port of connection's parent state return port.port_size[1] return ma...
As a Python code composer, you craft elegant and concise scripts.
def register_view(self, view): """Called when the View was registered""" super(DataPortListController, self).register_view(view) view['name_col'].add_attribute(view['name_text'], 'text', self.NAME_STORAGE_ID) view['data_type_col'].add_attribute(view['data_type_text'], 'text', self.DATA_...
Can you implement a function in Python 3 that calls when the View was registered
You are a Python code architect, reviewing and designing scalable and efficient code
def on_use_runtime_value_toggled(self, widget, path): """Try to set the use runtime value flag to the newly entered one """ try: data_port_id = self.list_store[path][self.ID_STORAGE_ID] self.toggle_runtime_value_usage(data_port_id) except TypeError as e: ...
How would you implement a function in Python 3 that tries to set the use runtime value flag to the newly entered one
You are a Python code architect, reviewing and designing scalable and efficient code
Function set renderer properties for every single cell independently
Can you generate the documentation for the following Python 3 function def _default_value_cell_data_func(self, tree_view_column, cell, model, iter, data=None): if isinstance(self.model.state, LibraryState): use_runtime_value = model.get_value(iter, self.USE_RUNTIME_VALUE_STORAGE_ID) if u...
As a Python code translator, you convert algorithms and pseudocode into Python.
def _reload_data_port_list_store(self): """Reloads the input data port list store from the data port models""" tmp = self._get_new_list_store() for data_port_m in self.data_port_model_list: data_port_id = data_port_m.data_port.data_port_id data_type = data_port_m.data_po...
Can you create a Python 3 function that reloads the input data port list store from the data port models
You are a Python code architect, reviewing and designing scalable and efficient code
def _apply_new_data_port_name(self, path, new_name): """Applies the new name of the data port defined by path :param str path: The path identifying the edited data port :param str new_name: New name """ try: data_port_id = self.list_store[path][self.ID_STORAGE_ID] ...
Write a Python 3 script for applying the new name of the data port defined by path to the state data port.
You are a Python code architect, reviewing and designing scalable and efficient code
def _apply_new_data_port_type(self, path, new_data_type_str): """Applies the new data type of the data port defined by path :param str path: The path identifying the edited data port :param str new_data_type_str: New data type as str """ try: data_port_id = self.list...
Write a Python 3 function for applying the new data type of the data port defined by path
You are a Python code architect, reviewing and designing scalable and efficient code
def _apply_new_data_port_default_value(self, path, new_default_value_str): """Applies the new default value of the data port defined by path :param str path: The path identifying the edited variable :param str new_default_value_str: New default value as string """ try: ...
Create a Python 3 function to apply the new default value of the data port defined by path
As a Python code composer, you craft elegant and concise scripts.
Reload list store and reminds selection when the model was changed
Here you have a function in Python 3, explain what it does def _data_ports_changed(self, model): if not isinstance(model, AbstractStateModel): return # store port selection path_list = None if self.view is not None: model, path_list = self.tree_view.get_selection(...
You are a Python code generator, capable of creating scripts from specifications.
def runtime_values_changed(self, model, prop_name, info): """Handle cases for the library runtime values""" if ("_input_runtime_value" in info.method_name or info.method_name in ['use_runtime_value_input_data_ports', 'input_data_port_runtime_values'])...
How would you implement a function in Python 3 that handles cases for the library runtime values
You are a Python code generator, capable of creating scripts from specifications.
def add_new_data_port(self): """Add a new port with default values and select it""" try: new_data_port_ids = gui_helper_state_machine.add_data_port_to_selected_states('OUTPUT', int, [self.model]) if new_data_port_ids: self.select_entry(new_data_port_ids[self.model...
Write a Python 3 function that can add a new data port with default values and select it
You are a Python code architect, reviewing and designing scalable and efficient code
Adds a callback function to an action.
Given the following Python 3 function, write the documentation def add_callback_for_action(self, action, callback): if hasattr(callback, '__call__'): # Is the callback really a function? if action not in self.__action_to_callbacks: self.__action_to_callbacks[action] = [] ...
You are a Python code architect, reviewing and designing scalable and efficient code
Remove a callback for a specific action
Given the following Python 3 function, write the documentation def remove_callback_for_action(self, action, callback): if action in self.__action_to_callbacks: if callback in self.__action_to_callbacks[action]: self.__action_to_callbacks[action].remove(callback)
As a Python code composer, you craft elegant and concise scripts.
Calls the appropriate callback function(s) for the given action and returns a boolean indicating whether a callback was triggered.
Make a summary of the following Python 3 code def trigger_action(self, action, key_value, modifier_mask): res = False if action in self.__action_to_callbacks: for callback_function in self.__action_to_callbacks[action]: try: ret = callback_function(key_val...
As a Python code translator, you convert algorithms and pseudocode into Python.
Stop updates while multi - actions are allowed
Here you have a function in Python 3, explain what it does def check_info_on_no_update_flags(self, info): # TODO that could need a second clean up # avoid updates because of state destruction if 'before' in info and info['method_name'] == "remove_state": if info.instance is self.mode...
You are a Python code generator, capable of creating scripts from specifications.
Check for multi - actions and set respective no update flags.
Can you tell what is the following Python 3 function doing def before_notification_state_machine_observation_control(self, model, prop_name, info): if is_execution_status_update_notification_from_state_machine_model(prop_name, info): return # do not update while multi-actions self.ch...
As a Python code translator, you convert algorithms and pseudocode into Python.
Stores the value of a certain variable with name with the given value and parameters.
Can you generate the documentation for the following Python 3 function def store_value(self, name, value, parameters=None): if not isinstance(parameters, dict): raise TypeError("parameters must be a dict") hash = self._parameter_hash(parameters) if name not in self._cache: ...
As a Python code composer, you craft elegant and concise scripts.
Return the value of a cached variable if applicable
How would you explain what the following Python 3 function does def get_value(self, name, parameters=None): if not isinstance(parameters, dict): raise TypeError("parameters must a dict") if name not in self._cache: return None hash = self._parameter_hash(parameters) ...
You are a Python code generator, capable of creating scripts from specifications.
Assures equal precision for all number values
Can you generate a brief explanation for the following Python 3 code def _normalize_number_values(self, parameters): for key, value in parameters.items(): if isinstance(value, (int, float)): parameters[key] = str(Decimal(value).normalize(self._context))
You are a Python code architect, reviewing and designing scalable and efficient code
Register callbacks for button press events and selection changed
Here you have a function in Python 3, explain what it does def register_view(self, view): super(AbstractTreeViewController, self).register_view(view) self.signal_handlers.append((self._tree_selection, self._tree_selection.connect('changed', self.selection_changed))) ...
As a Python code composer, you craft elegant and concise scripts.
def get_view_selection(self): """Get actual tree selection object and all respective models of selected rows""" if not self.MODEL_STORAGE_ID: return None, None # avoid selection requests on empty tree views -> case warnings in gtk3 if len(self.store) == 0: paths ...
Implement a Python 3 function for getting actual tree selection object and all respective models of selected rows
As a Python code analyst, you investigate and solve complex coding mysteries
Get current model selection status in state machine selection and view selection of the widget
Can you generate the documentation for the following Python 3 function def get_selections(self): sm_selection, sm_filtered_selected_model_set = self.get_state_machine_selection() tree_selection, selected_model_list = self.get_view_selection() return tree_selection, selected_model_list, sm_select...
You are a Python code generator, capable of creating scripts from specifications.
def state_machine_selection_changed(self, state_machine_m, signal_name, signal_msg): """Notify tree view about state machine selection""" if self.CORE_ELEMENT_CLASS in signal_msg.arg.affected_core_element_classes: self.update_selection_sm_prior()
Can you write a function in Python 3 where it notifies tree view about state machine selection
You are a Python code architect, reviewing and designing scalable and efficient code
Callback method for add action
Make a summary of the following Python 3 code def add_action_callback(self, *event): if react_to_event(self.view, self.tree_view, event) and self.active_entry_widget is None: self.on_add(None) return True
As a python code expert, you are capable of creating scripts from specifications.
Callback method for cut action
Can you generate a brief explanation for the following Python 3 code def cut_action_callback(self, *event): if react_to_event(self.view, self.tree_view, event) and self.active_entry_widget is None: sm_selection, sm_selected_model_list = self.get_state_machine_selection() # only list spec...
You are a Python code generator, capable of creating scripts from specifications.
Set up the renderer to apply changes when loosing focus out
Can you generate the documentation for the following Python 3 function def _apply_value_on_edited_and_focus_out(self, renderer, apply_method): assert isinstance(renderer, Gtk.CellRenderer) def remove_all_handler(renderer): """Remove all handler for given renderer and its editable ...
You are a Python code analyst, evaluating scripts for potential improvements.
This method is called by the key press event handler to adapt the tree view and controller behavior according to the key release events.
Can you generate the documentation for the following Python 3 function def tree_view_keypress_callback(self, widget, event): current_row_path, current_focused_column = self.tree_view.get_cursor() # print(current_row_path, current_focused_column) if isinstance(widget, Gtk.TreeView) and not self.a...
As a Python code translator, you convert algorithms and pseudocode into Python.
Register callbacks for button press events and selection changed
Make a summary of the following Python 3 code def register_view(self, view): super(ListViewController, self).register_view(view) self.tree_view.connect('button_press_event', self.mouse_click)
You are a Python code analyst, evaluating scripts for potential improvements.
def on_remove(self, widget, data=None): """Removes respective selected core elements and select the next one""" path_list = None if self.view is not None: model, path_list = self.tree_view.get_selection().get_selected_rows() old_path = self.get_path() models = [self....
Create a Python 3 function to remove respective selected core elements and select the next one
You are a Python code generator, capable of creating scripts from specifications.
def mouse_click(self, widget, event=None): """Implements shift- and control-key handling features for mouse button press events explicit The method is implements a fully defined mouse pattern to use shift- and control-key for multi-selection in a TreeView and a ListStore as model. It avoid pr...
Write a Python 3 script for implementing mouse click events explicit iloilo
You are a Python code generator, capable of creating scripts from specifications.
def _handle_double_click(self, event): """ Double click with left mouse button focuses the element""" 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 entry was clicked on ...
Can you implement a function in Python 3 that doubles click with left mouse button focuses the element
You are a Python code architect, reviewing and designing scalable and efficient code
def update_selection_sm_prior(self): """State machine prior update of tree selection""" if self._do_selection_update: return self._do_selection_update = True tree_selection, selected_model_list, sm_selection, sm_selected_model_list = self.get_selections() if tree_sele...
Can you implement a function in Python 3 that updates state machine prior update of tree selection
You are a Python code analyst, evaluating scripts for potential improvements.
def update_selection_self_prior(self): """Tree view prior update of state machine selection""" if self._do_selection_update: return self._do_selection_update = True tree_selection, selected_model_list, sm_selection, sm_selected_model_list = self.get_selections() if is...
Can you create a Python 3 function that updates tree view prior of state machine selection
As a Python code translator, you convert algorithms and pseudocode into Python.
def select_entry(self, core_element_id, by_cursor=True): """Selects the row entry belonging to the given core_element_id by cursor or tree selection""" for row_num, element_row in enumerate(self.list_store): # Compare data port ids if element_row[self.ID_STORAGE_ID] == core_eleme...
Can you implement a function in Python 3 that selects the row entry belonging to the given core_element_id by cursor or tree selection
As a Python code analyst, you investigate and solve complex coding mysteries
Get the path to the row representing the core element described by handed core_element_id
Make a summary of the following Python 3 code def get_path_for_core_element(self, core_element_id): for row_num, element_row in enumerate(self.list_store): # Compare data port ids if element_row[self.ID_STORAGE_ID] == core_element_id: return row_num,
As a python code expert, you are capable of creating scripts from specifications.
This method is called by the key press event handler for the tree view. It is used to create a new list item and edit process.
Given the following Python 3 function, write the documentation def tree_view_keypress_callback(self, widget, event): # self._logger.info("key_value: " + str(event.keyval if event is not None else '')) if event and "GDK_KEY_PRESS" == event.type.value_name \ and (event.keyval == Gdk.KEY_Ta...
As a Python code analyst, you investigate and solve complex coding mysteries
Iterate tree view with condition check function
Explain what the following Python 3 code does def iter_tree_with_handed_function(self, function, *function_args): def iter_all_children(row_iter, function, function_args): if isinstance(row_iter, Gtk.TreeIter): function(row_iter, *function_args) for n in reversed(rang...
As a Python code translator, you convert algorithms and pseudocode into Python.
def update_selection_sm_prior_condition(self, state_row_iter, selected_model_list, sm_selected_model_list): """State machine prior update of tree selection for one tree model row""" selected_path = self.tree_store.get_path(state_row_iter) tree_model_row = self.tree_store[selected_path] m...
How would you code a function in Python 3 to update tree selection prior condition of tree model row
As a Python code translator, you convert algorithms and pseudocode into Python.
Tree view prior update of one model in the state machine selection
Given the following Python 3 function, write the documentation def update_selection_self_prior_condition(self, state_row_iter, sm_selected_model_set, selected_model_list): selected_path = self.tree_store.get_path(state_row_iter) tree_model_row = self.tree_store[selected_path] model = tree_model_...
As a Python code analyst, you investigate and solve complex coding mysteries
def update_selection_self_prior(self): """Tree view prior update of state machine selection""" if self._do_selection_update: return self._do_selection_update = True tree_selection, selected_model_list, sm_selection, sm_selected_model_set = self.get_selections() if isi...
How would you implement a function in Python 3 that updates tree view prior of state machine selection
You are a Python code analyst, evaluating scripts for potential improvements.
State machine prior update of tree selection
Here you have a function in Python 3, explain what it does def update_selection_sm_prior(self): if self._do_selection_update: return self._do_selection_update = True tree_selection, selected_model_list, sm_selection, sm_selected_model_list = self.get_selections() if tree_sele...
You are a Python code architect, reviewing and designing scalable and efficient code
def select_entry(self, core_element_id, by_cursor=True): """Selects the row entry belonging to the given core_element_id by cursor or tree selection""" path = self.get_path_for_core_element(core_element_id) if path: if by_cursor: self.tree_view.set_cursor(path) ...
Can you write a function in Python 3 where it selects the row entry belonging to the given core_element_id by cursor or tree selection
You are a Python code analyst, evaluating scripts for potential improvements.
def contains_geometric_info(var): """ Check whether the passed variable is a tuple with two floats or integers """ return isinstance(var, tuple) and len(var) == 2 and all(isinstance(val, (int, float)) for val in var)
Write a Python 3 script to check whether the passed variable is a tuple with two floats or integers
As a Python code analyst, you investigate and solve complex coding mysteries
def generate_default_state_meta_data(parent_state_m, canvas=None, num_child_state=None, gaphas_editor=True): """Generate default meta data for a child state according its parent state The function could work with the handed num_child_state if all child state are not drawn, till now. The method checks if th...
Create a Python 3 function to generate default meta data for a child state according its parent state model
As a Python code translator, you convert algorithms and pseudocode into Python.
Increase the space between left and right and top and bottom and the function increase the space between left and right and between top and bottom and between left and right parameters.
Can you generate the documentation for the following Python 3 function def add_boundary_clearance(left, right, top, bottom, frame, clearance=0.1): # print("old boundary", left, right, top, bottom) width = right - left width = frame['size'][0] if width < frame['size'][0] else width left -= 0.5 * clearan...
As a Python code translator, you convert algorithms and pseudocode into Python.
def get_boundaries_of_elements_in_dict(models_dict, clearance=0.): """ Get boundaries of all handed models The function checks all model meta data positions to increase boundary starting with a state or scoped variables. It is finally iterated over all states, data and logical port models and linkage if su...
Create a Python 3 function for getting boundaries of all models in a dictionary.
As a python code expert, you are capable of creating scripts from specifications.
Generate margin relative position and size handed boundary parameter and parent size
Can you tell what is the following Python 3 function doing def cal_frame_according_boundaries(left, right, top, bottom, parent_size, gaphas_editor=True, group=True): # print("parent_size ->", parent_size) margin = cal_margin(parent_size) # Add margin and ensure that the upper left corner is within the state...
As a python code expert, you are capable of creating scripts from specifications.
def offset_rel_pos_of_all_models_in_dict(models_dict, pos_offset, gaphas_editor=True): """ Add position offset to all handed models in dict""" # print("\n", "#"*30, "offset models", pos_offset, "#"*30) # Update relative position of states within the container in order to maintain their absolute position ...
Can you write a function in Python 3 where it adds relative position offset to all handed models in dict
As a python code expert, you are capable of creating scripts from specifications.
def scale_library_ports_meta_data(state_m, gaphas_editor=True): """Scale the ports of library model accordingly relative to state_copy meta size. The function assumes that the meta data of ports of the state_copy of the library was copied to respective elements in the library and that those was not ad...
Can you create a Python 3 function that scales the ports of the library model accordingly relative to the state_copy meta size.
As a Python code analyst, you investigate and solve complex coding mysteries
def scale_library_content(library_state_m, gaphas_editor=True): """Scales the meta data of the content of a LibraryState The contents of the `LibraryStateModel` `library_state_m` (i.e., the `state_copy` and all it children/state elements) to fit the current size of the `LibraryStateModel`. :p...
Can you create a Python 3 function that scales the meta data of the content of a LibraryStateModel to fit the current size of the LibraryStateModel.
As a Python code translator, you convert algorithms and pseudocode into Python.
Resize data and logical ports relative positions
Make a summary of the following Python 3 code def resize_state_port_meta(state_m, factor, gaphas_editor=True): # print("scale ports", factor, state_m, gaphas_editor) if not gaphas_editor and isinstance(state_m, ContainerStateModel): port_models = state_m.input_data_ports[:] + state_m.output_data_ports[:...
As a Python code translator, you convert algorithms and pseudocode into Python.
Resize state meta data recursively what includes also LibraryStateModels meta data and its internal state_copy
How would you explain what the following Python 3 function does def resize_state_meta(state_m, factor, gaphas_editor=True): # print("START RESIZE OF STATE", state_m.get_meta_data_editor(for_gaphas=gaphas_editor), state_m) old_rel_pos = state_m.get_meta_data_editor(for_gaphas=gaphas_editor)['rel_pos'] # prin...
As a Python code translator, you convert algorithms and pseudocode into Python.
Offset meta data of state elements according the area used indicated by the state meta data.
Can you tell what is the following Python 3 function doing def offset_rel_pos_of_models_meta_data_according_parent_state(models_dict): old_parent_rel_pos = models_dict['state'].get_meta_data_editor()['rel_pos'] offset_rel_pos_of_all_models_in_dict(models_dict, pos_offset=old_parent_rel_pos) return True
You are a Python code generator, capable of creating scripts from specifications.
Scale meta data according states of group states.
Can you generate the documentation for the following Python 3 function def scale_meta_data_according_states(models_dict): left, right, top, bottom = get_boundaries_of_elements_in_dict(models_dict=models_dict) parent_size = models_dict['state'].parent.get_meta_data_editor()['size'] _, rel_pos, size = cal_fr...
You are a Python code analyst, evaluating scripts for potential improvements.
def scale_meta_data_according_state(models_dict, rel_pos=None, as_template=False, fill_up=False): # TODO Documentation needed.... """ Scale elements in dict to fit into dict state key element. If elements are already small enough no resize is performed. """ # TODO check about positions of input-dat...
How would you implement a function in Python 3 that scales meta - data according to state.
As a Python code composer, you craft elegant and concise scripts.
Calculate the closest sibling state from optional logical port of handed state model
Explain what the following Python 3 code does def get_closest_sibling_state(state_m, from_logical_port=None): if not state_m.parent: logger.warning("A state can not have a closest sibling state if it has not parent as {0}".format(state_m)) return margin = cal_margin(state_m.parent.get_meta_data...
As a Python code translator, you convert algorithms and pseudocode into Python.