output stringlengths 1 928k | instruction stringlengths 7 928k | system stringlengths 0 104k |
|---|---|---|
Updates the corresponding list store entry for a changed config value | Explain what the following Python 3 code does
def update_config_value(self, config_m, config_key):
config_value = config_m.get_current_config_value(config_key)
if config_m is self.core_config_model:
list_store = self.core_list_store
elif config_m is self.gui_config_model:
... | As a Python code translator, you convert algorithms and pseudocode into Python. |
Helper method to update a list store entry | Here you have a function in Python 3, explain what it does
def _update_list_store_entry(self, list_store, config_key, config_value):
for row_num, row in enumerate(list_store):
if row[self.KEY_STORAGE_ID] == config_key:
row[self.VALUE_STORAGE_ID] = str(config_value)
ro... | You are a Python code generator, capable of creating scripts from specifications. |
Generic method to update list store for a given config model | Can you generate a brief explanation for the following Python 3 code
def _update_list_store(config_m, list_store, ignore_keys=None):
ignore_keys = [] if ignore_keys is None else ignore_keys
list_store.clear()
for config_key in sorted(config_m.config.keys):
if config_key in ignore_key... | You are a Python code analyst, evaluating scripts for potential improvements. |
Updates the list store for the libraries that are currently loaded. | How would you explain what the following Python 3 function does
def update_libraries_list_store(self):
self.library_list_store.clear()
libraries = self.core_config_model.get_current_config_value("LIBRARY_PATHS", use_preliminary=True, default={})
library_names = sorted(libraries.keys())
f... | You are a Python code analyst, evaluating scripts for potential improvements. |
def update_shortcut_settings(self):
"""Creates the list store for the shortcuts
"""
self.shortcut_list_store.clear()
shortcuts = self.gui_config_model.get_current_config_value("SHORTCUTS", use_preliminary=True, default={})
actions = sorted(shortcuts.keys())
for action in ... | Can you write a function in Python 3 where it
updates the list store for the shortcuts | As a Python code composer, you craft elegant and concise scripts. |
Helper method to select a tree view row by column value | Explain what the following Python 3 code does
def _select_row_by_column_value(tree_view, list_store, column, value):
for row_num, iter_elem in enumerate(list_store):
if iter_elem[column] == value:
tree_view.set_cursor(row_num)
return row_num | You are a Python code analyst, evaluating scripts for potential improvements. |
Callback method handling the addition of a new library | Can you generate the documentation for the following Python 3 function
def _on_add_library(self, *event):
self.view['library_tree_view'].grab_focus()
if react_to_event(self.view, self.view['library_tree_view'], event):
temp_library_name = "<LIB_NAME_%s>" % self._lib_counter
self.... | You are a Python code analyst, evaluating scripts for potential improvements. |
Callback method handling the removal of an existing library | Given the following Python 3 function, write the documentation
def _on_remove_library(self, *event):
self.view['library_tree_view'].grab_focus()
if react_to_event(self.view, self.view['library_tree_view'], event):
path = self.view["library_tree_view"].get_cursor()[0]
if path is n... | As a Python code composer, you craft elegant and concise scripts. |
Callback method that is called when a checkbox is toggled | Explain what the following Python 3 code does
def _on_checkbox_toggled(self, renderer, path, config_m, config_list_store):
config_key = config_list_store[int(path)][self.KEY_STORAGE_ID]
config_value = bool(config_list_store[int(path)][self.TOGGLE_VALUE_STORAGE_ID])
config_value ^= True
c... | As a python code expert, you are capable of creating scripts from specifications. |
def _on_ok_button_clicked(self, *args):
"""OK button clicked: Applies the configurations and closes the window
"""
if self.core_config_model.preliminary_config or self.gui_config_model.preliminary_config:
self._on_apply_button_clicked()
self.__destroy() | Can you implement a function in Python 3 that
applies the configurations and closes the window | As a python code expert, you are capable of creating scripts from specifications. |
def _on_cancel_button_clicked(self, *args):
"""Cancel button clicked: Dismiss preliminary config and close the window
"""
self.core_config_model.preliminary_config.clear()
self.gui_config_model.preliminary_config.clear()
self.__destroy() | Write a Python 3 function that can
dismiss preliminary config and close the window | As a Python code analyst, you investigate and solve complex coding mysteries |
Apply button clicked: Apply the configuration | Here you have a function in Python 3, explain what it does
def _on_apply_button_clicked(self, *args):
refresh_required = self.core_config_model.apply_preliminary_config()
refresh_required |= self.gui_config_model.apply_preliminary_config()
if not self.gui_config_model.config.get_config_value("S... | You are a Python code generator, capable of creating scripts from specifications. |
Callback for when a new entry in the list store has changed | Here you have a function in Python 3, explain what it does
def _on_shortcut_changed(self, renderer, path, new_shortcuts):
action = self.shortcut_list_store[int(path)][self.KEY_STORAGE_ID]
old_shortcuts = self.gui_config_model.get_current_config_value("SHORTCUTS", use_preliminary=True)[action]
f... | You are a Python code architect, reviewing and designing scalable and efficient code |
Callback for when a config value is changed | Can you tell what is the following Python 3 function doing
def _on_config_value_changed(self, renderer, path, new_value, config_m, list_store):
config_key = list_store[int(path)][self.KEY_STORAGE_ID]
old_value = config_m.get_current_config_value(config_key, use_preliminary=True)
if old_value ==... | As a python code expert, you are capable of creating scripts from specifications. |
Function that opens a dialog to select which config shall be exported | Can you tell what is the following Python 3 function doing
def _config_chooser_dialog(self, title_text, description):
dialog = Gtk.Dialog(title_text, self.view["preferences_window"],
flags=0, buttons=
(Gtk.STOCK_CANCEL, Gtk.ResponseType.REJECT,
... | You are a Python code analyst, evaluating scripts for potential improvements. |
def check_if_dict_contains_object_reference_in_values(object_to_check, dict_to_check):
""" Method to check if an object is inside the values of a dict.
A simple object_to_check in dict_to_check.values() does not work as it uses the __eq__ function of the object
and not the object reference.
:param obje... | Write a Python 3 function for
checking if an object is inside the values of a dict. | As a Python code composer, you craft elegant and concise scripts. |
Updates the data flow dictionary and combo dictionary of the widget according handed model. | Here you have a function in Python 3, explain what it does
def update_data_flows(model, data_flow_dict, tree_dict_combos):
data_flow_dict['internal'] = {}
data_flow_dict['external'] = {}
tree_dict_combos['internal'] = {}
tree_dict_combos['external'] = {}
# free input ports and scopes are real to_ke... | You are a Python code generator, capable of creating scripts from specifications. |
Called when the View was registered | Make a summary of the following Python 3 code
def register_view(self, view):
super(StateDataFlowsListController, self).register_view(view)
def cell_text(column, cell_renderer, model, iter, container_model):
df_id = model.get_value(iter, self.ID_STORAGE_ID)
in_external = 'externa... | You are a Python code generator, capable of creating scripts from specifications. |
def remove_core_element(self, model):
"""Remove respective core element of handed data flow model
:param DataFlowModel model: Data Flow model which core element should be removed
:return:
"""
assert model.data_flow.parent is self.model.state or model.data_flow.parent is self.mod... | Write a Python 3 script to
remove respective core element of handed data flow model | As a Python code composer, you craft elegant and concise scripts. |
def register_view(self, view):
"""Called when the View was registered
Can be used e.g. to connect signals. Here, the destroy signal is connected to close the application
"""
super(StateDataFlowsEditorController, self).register_view(view)
view['add_d_button'].connect('clicked', s... | Create a Python 3 function for
calling when the view was registered | As a Python code composer, you craft elegant and concise scripts. |
def start(self):
"""Starts the execution of the root state.
"""
# load default input data for the state
self._root_state.input_data = self._root_state.get_default_input_values_for_state(self._root_state)
self._root_state.output_data = self._root_state.create_output_dictionary_for... | Can you implement a function in Python 3 that
starts the execution of the root state. | As a Python code composer, you craft elegant and concise scripts. |
Wait for root state to finish execution | How would you explain what the following Python 3 function does
def join(self):
self._root_state.join()
# execution finished, close execution history log file (if present)
if len(self._execution_histories) > 0:
if self._execution_histories[-1].execution_history_storage is not None:
... | You are a Python code analyst, evaluating scripts for potential improvements. |
Calculates the drawing area affected by the port. | Make a summary of the following Python 3 code
def get_port_area(self, view):
state_v = self.parent
center = self.handle.pos
margin = self.port_side_size / 4.
if self.side in [SnappedSide.LEFT, SnappedSide.RIGHT]:
height, width = self.port_size
else:
width,... | As a Python code analyst, you investigate and solve complex coding mysteries |
def _draw_simple_state_port(self, context, direction, color, transparency):
"""Draw the port of a simple state (ExecutionState, LibraryState)
Connector for execution states can only be connected to the outside. Thus the connector fills the whole
border of the state.
:param context: Cai... | Write a Python 3 function that can
draw the simple state port of a simple state. | As a Python code analyst, you investigate and solve complex coding mysteries |
Draw the port of a container state. | Here you have a function in Python 3, explain what it does
def _draw_container_state_port(self, context, direction, color, transparency):
c = context
width, height = self.port_size
c.set_line_width(self.port_side_size / constants.BORDER_WIDTH_OUTLINE_WIDTH_FACTOR *
self... | You are a Python code generator, capable of creating scripts from specifications. |
def _draw_single_connector(context, width, height):
"""Draw the connector for execution states
Connector for execution states can only be connected to the outside. Thus the connector fills the whole
border of the state.
:param context: Cairo context
:param float port_size: The ... | Write a Python 3 function that can
draw the connector for execution states in a single context. | You are a Python code generator, capable of creating scripts from specifications. |
def _draw_inner_connector(context, width, height):
"""Draw the connector for container states
Connector for container states can be connected from the inside and the outside. Thus the connector is split
in two parts: A rectangle on the inside and an arrow on the outside. This methods draws the ... | How would you code a function in Python 3 to
draw the connector for container states | You are a Python code generator, capable of creating scripts from specifications. |
def _draw_outer_connector(context, width, height):
"""Draw the outer connector for container states
Connector for container states can be connected from the inside and the outside. Thus the connector is split
in two parts: A rectangle on the inside and an arrow on the outside. This method draws... | Create a Python 3 function for
drawing the outer connector for container states. | As a python code expert, you are capable of creating scripts from specifications. |
Draw a rectangle of the current size | How would you explain what the following Python 3 function does
def _draw_rectangle(context, width, height):
c = context
# First move to upper left corner
c.rel_move_to(-width / 2., -height / 2.)
# Draw closed rectangle
c.rel_line_to(width, 0)
c.rel_line_to(0, height)
... | You are a Python code analyst, evaluating scripts for potential improvements. |
def _rotate_context(context, direction):
"""Moves the current position to 'position' and rotates the context according to 'direction'
:param context: Cairo context
:param direction: Direction enum
"""
if direction is Direction.UP:
pass
elif direction is Direc... | Can you implement a function in Python 3 that
moves the current position to position and rotates the context according to direction | As a python code expert, you are capable of creating scripts from specifications. |
Draws the name of the port. | Given the following Python 3 function, write the documentation
def draw_name(self, context, transparency, only_calculate_size=False):
c = context
cairo_context = c
if isinstance(c, CairoBoundingBoxContext):
cairo_context = c._cairo
# c.set_antialias(Antialias.GOOD)
s... | As a python code expert, you are capable of creating scripts from specifications. |
def _draw_rectangle_path(self, context, width, height, only_get_extents=False):
"""Draws the rectangle path for the port
The rectangle is correctly rotated. Height therefore refers to the border thickness and width to the length
of the port.
:param context: The context to draw on
... | Can you write a function in Python 3 where it
draws the rectangle path for the port. | As a Python code translator, you convert algorithms and pseudocode into Python. |
Calculates the center position of the port rectangle. | Here you have a function in Python 3, explain what it does
def _get_port_center_position(self, width):
x, y = self.pos.x.value, self.pos.y.value
if self.side is SnappedSide.TOP or self.side is SnappedSide.BOTTOM:
if x - width / 2. < 0:
x = width / 2
elif x + width... | You are a Python code generator, capable of creating scripts from specifications. |
Register callback methods for triggered actions
| How would you explain what the following Python 3 function does
def register_actions(self, shortcut_manager):
shortcut_manager.add_callback_for_action('rename', self.rename_selected_state)
super(StatesEditorController, self).register_actions(shortcut_manager) | You are a Python code architect, reviewing and designing scalable and efficient code |
def get_current_state_m(self):
"""Returns the state model of the currently open tab"""
page_id = self.view.notebook.get_current_page()
if page_id == -1:
return None
page = self.view.notebook.get_nth_page(page_id)
state_identifier = self.get_state_identifier_for_page(p... | Write a Python 3 script to
return the state model of the currently open tab | You are a Python code generator, capable of creating scripts from specifications. |
Triggered whenever a new state machine is created or selected. | Make a summary of the following Python 3 code
def state_machine_manager_notification(self, model, property, info):
if self.current_state_machine_m is not None:
selection = self.current_state_machine_m.selection
if len(selection.states) > 0:
self.activate_state_tab(selecti... | You are a Python code analyst, evaluating scripts for potential improvements. |
Method remove state - tabs for those no state machine exists anymore. | Can you generate a brief explanation for the following Python 3 code
def clean_up_tabs(self):
tabs_to_close = []
for state_identifier, tab_dict in list(self.tabs.items()):
if tab_dict['sm_id'] not in self.model.state_machine_manager.state_machines:
tabs_to_close.append(state_... | You are a Python code generator, capable of creating scripts from specifications. |
def state_machines_set_notification(self, model, prop_name, info):
"""Observe all open state machines and their root states
"""
if info['method_name'] == '__setitem__':
state_machine_m = info.args[1]
self.observe_model(state_machine_m) | How would you implement a function in Python 3 that
observes all open state machines and their root states | As a Python code translator, you convert algorithms and pseudocode into Python. |
def state_machines_del_notification(self, model, prop_name, info):
"""Relive models of closed state machine
"""
if info['method_name'] == '__delitem__':
state_machine_m = info["result"]
try:
self.relieve_model(state_machine_m)
except KeyError:
... | Can you implement a function in Python 3 that
relives models of closed state machine | As a Python code translator, you convert algorithms and pseudocode into Python. |
Triggered whenever a state is selected. | Can you tell what is the following Python 3 function doing
def add_state_editor(self, state_m):
state_identifier = self.get_state_identifier(state_m)
if state_identifier in self.closed_tabs:
state_editor_ctrl = self.closed_tabs[state_identifier]['controller']
state_editor_view =... | As a Python code composer, you craft elegant and concise scripts. |
def script_text_changed(self, text_buffer, state_m):
""" Update gui elements according text buffer changes
Checks if the dirty flag needs to be set and the tab label to be updated.
:param TextBuffer text_buffer: Text buffer of the edited script
:param rafcon.gui.models.state.StateModel... | How would you code a function in Python 3 to
update the gui elements according text buffer changes | You are a Python code analyst, evaluating scripts for potential improvements. |
def destroy_page(self, tab_dict):
""" Destroys desired page
Disconnects the page from signals and removes interconnection to parent-controller or observables.
:param tab_dict: Tab-dictionary that holds all necessary information of a page and state-editor.
"""
# logger.info("des... | Create a Python 3 function for
destroying the desired page and disconnects the page from signals and removes interconnection to parent - controller or observables. | You are a Python code architect, reviewing and designing scalable and efficient code |
def close_page(self, state_identifier, delete=True):
"""Closes the desired page
The page belonging to the state with the specified state_identifier is closed. If the deletion flag is set to
False, the controller of the page is stored for later usage.
:param state_identifier: Identifier... | How would you code a function in Python 3 to
close the desired page with the specified state_identifier. | As a Python code translator, you convert algorithms and pseudocode into Python. |
def find_page_of_state_m(self, state_m):
"""Return the identifier and page of a given state model
:param state_m: The state model to be searched
:return: page containing the state and the state_identifier
"""
for state_identifier, page_info in list(self.tabs.items()):
... | Write a Python 3 script for
returning the identifier and page of a given state model | As a Python code analyst, you investigate and solve complex coding mysteries |
Triggered when the states - editor close button is clicked
Closes the tab. | Can you generate a brief explanation for the following Python 3 code
def on_tab_close_clicked(self, event, state_m):
[page, state_identifier] = self.find_page_of_state_m(state_m)
if page:
self.close_page(state_identifier, delete=False) | As a Python code translator, you convert algorithms and pseudocode into Python. |
Closes all tabs of the states editor | Explain what the following Python 3 code does
def close_all_pages(self):
states_to_be_closed = []
for state_identifier in self.tabs:
states_to_be_closed.append(state_identifier)
for state_identifier in states_to_be_closed:
self.close_page(state_identifier, delete=False) | You are a Python code analyst, evaluating scripts for potential improvements. |
def close_pages_for_specific_sm_id(self, sm_id):
"""Closes all tabs of the states editor for a specific sm_id"""
states_to_be_closed = []
for state_identifier in self.tabs:
state_m = self.tabs[state_identifier]["state_m"]
if state_m.state.get_state_machine().state_machine... | Write a Python 3 function that can
close all tabs of the states editor for a specific sm_id | As a python code expert, you are capable of creating scripts from specifications. |
def on_switch_page(self, notebook, page_pointer, page_num, user_param1=None):
"""Update state selection when the active tab was changed
"""
page = notebook.get_nth_page(page_num)
# find state of selected tab
for tab_info in list(self.tabs.values()):
if tab_info['page... | How would you implement a function in Python 3 that
updates state selection when the active tab was changed | As a Python code analyst, you investigate and solve complex coding mysteries |
def activate_state_tab(self, state_m):
"""Opens the tab for the specified state model
The tab with the given state model is opened or set to foreground.
:param state_m: The desired state model (the selected state)
"""
# The current shown state differs from the desired one
... | How would you implement a function in Python 3 that
opens the tab for the given state model. | As a python code expert, you are capable of creating scripts from specifications. |
Keep only sticked and selected tabs | Can you generate a brief explanation for the following Python 3 code
def keep_only_sticked_and_selected_tabs(self):
# Only if the user didn't deactivate this behaviour
if not global_gui_config.get_config_value('KEEP_ONLY_STICKY_STATES_OPEN', True):
return
page_id = self.view.noteboo... | You are a Python code analyst, evaluating scripts for potential improvements. |
def notify_state_name_change(self, model, prop_name, info):
"""Checks whether the name of a state was changed and change the tab label accordingly
"""
# avoid updates or checks because of execution status updates
if is_execution_status_update_notification_from_state_machine_model(prop_na... | Create a Python 3 function for
checking whether the name of a state was changed and change the tab label accordingly. | As a Python code composer, you craft elegant and concise scripts. |
Update all tab labels that are currently open for the given state_m. | Can you generate a brief explanation for the following Python 3 code
def update_tab_label(self, state_m):
state_identifier = self.get_state_identifier(state_m)
if state_identifier not in self.tabs and state_identifier not in self.closed_tabs:
return
tab_info = self.tabs[state_identif... | You are a Python code analyst, evaluating scripts for potential improvements. |
def get_state_identifier_for_page(self, page):
"""Return the state identifier for a given page
"""
for identifier, page_info in list(self.tabs.items()):
if page_info["page"] is page: # reference comparison on purpose
return identifier | Write a Python 3 script to
return the state identifier for a given page | You are a Python code analyst, evaluating scripts for potential improvements. |
Callback method for shortcut action rename_selected_state | Here you have a function in Python 3, explain what it does
def rename_selected_state(self, key_value, modifier_mask):
selection = self.current_state_machine_m.selection
if len(selection.states) == 1 and len(selection) == 1:
selected_state = selection.get_selected_state()
self.act... | As a Python code composer, you craft elegant and concise scripts. |
Generate a new and unique semantic data key. | Can you generate a brief explanation for the following Python 3 code
def generate_semantic_data_key(used_semantic_keys):
semantic_data_id_counter = -1
while True:
semantic_data_id_counter += 1
if "semantic data key " + str(semantic_data_id_counter) not in used_semantic_keys:
break
... | As a Python code analyst, you investigate and solve complex coding mysteries |
def state_id_generator(size=STATE_ID_LENGTH, chars=string.ascii_uppercase, used_state_ids=None):
""" Create a new and unique state id
Generates an id for a state. It randomly samples from random ascii uppercase letters size times
and concatenates them. If the id already exists it draws a new one.
:par... | Write a Python 3 script to
generate a new state id for a state. | As a Python code analyst, you investigate and solve complex coding mysteries |
def global_variable_id_generator(size=10, chars=string.ascii_uppercase):
""" Create a new and unique global variable id
Generates an id for a global variable. It randomly samples from random ascii uppercase letters size times
and concatenates them. If the id already exists it draws a new one.
:param s... | Implement a Python 3 function for
generating a new id for a global variable. | You are a Python code architect, reviewing and designing scalable and efficient code |
Set the color as current OpenGL color | Given the following Python 3 function, write the documentation
def set(self):
glColor4f(self.r, self.g, self.b, self.a) | You are a Python code architect, reviewing and designing scalable and efficient code |
def _configure(self, *args):
"""Configure viewport
This method is called when the widget is resized or something triggers a redraw. The method configures the
view to show all elements in an orthogonal perspective.
"""
# Obtain a reference to the OpenGL drawable
# and ren... | Write a Python 3 script for
configuring viewport This method is called when the widget is resized or a redraw is triggered. | You are a Python code generator, capable of creating scripts from specifications. |
def pixel_to_size_ratio(self):
"""Calculates the ratio between pixel and OpenGL distances
OpenGL keeps its own coordinate system. This method can be used to transform between pixel and OpenGL
coordinates.
:return: pixel/size ratio
"""
left, right, _, _ = self.get_view_c... | How would you code a function in Python 3 to
calculate the ratio between pixel and OpenGL s view coordinates. | As a python code expert, you are capable of creating scripts from specifications. |
def expose_init(self, *args):
"""Process the drawing routine
"""
# Obtain a reference to the OpenGL drawable
# and rendering context.
gldrawable = self.get_gl_drawable()
glcontext = self.get_gl_context()
# OpenGL begin
if not gldrawable or not gldrawable.... | Write a Python 3 function for
exposing the drawing routine to the current rendering context. | You are a Python code generator, capable of creating scripts from specifications. |
def draw_state(self, name, pos, size, outcomes=None, input_ports_m=None, output_ports_m=None, selected=False,
active=False, depth=0):
"""Draw a state with the given properties
This method is called by the controller to draw the specified (container) state.
:param name: Name ... | Can you implement a function in Python 3 that
draws a state with the given properties This method is called by the controller to draw the specified (container) state. :param name: Name of the state :param pos: position (x, y) of the state :param size: size (width, height) of the state :param outcomes: outcomes of the s... | You are a Python code analyst, evaluating scripts for potential improvements. |
def draw_transition(self, from_pos, to_pos, width, waypoints=None, selected=False, depth=0):
"""Draw a state with the given properties
This method is called by the controller to draw the specified transition.
:param tuple from_pos: Starting position
:param tuple to_pos: Ending position... | How would you code a function in Python 3 to
draw a state with the given properties This method is called by the controller to draw the specified transition. :param tuple from_pos: Starting position :param tuple to_pos: Ending position :param float width: A measure for the width of a transition line :param list waypoin... | You are a Python code analyst, evaluating scripts for potential improvements. |
Write a string with a simple OpenGL method. | Can you generate the documentation for the following Python 3 function
def _write_string(self, string, pos_x, pos_y, height, color, bold=False, align_right=False, depth=0.):
stroke_width = height / 8.
if bold:
stroke_width = height / 5.
color.set()
self._set_closest_stroke_wi... | As a Python code analyst, you investigate and solve complex coding mysteries |
Prepares the selection rendering for the object being clicked on. | Here you have a function in Python 3, explain what it does
def prepare_selection(self, pos_x, pos_y, width, height):
glSelectBuffer(self.name_counter * 6)
viewport = glGetInteger(GL_VIEWPORT)
glMatrixMode(GL_PROJECTION)
glPushMatrix()
glRenderMode(GL_SELECT)
glLoadIden... | As a Python code translator, you convert algorithms and pseudocode into Python. |
Finds the selected ids of the selected objects | Make a summary of the following Python 3 code
def find_selection():
hits = glRenderMode(GL_RENDER)
glMatrixMode(GL_PROJECTION)
glPopMatrix()
glMatrixMode(GL_MODELVIEW)
return hits | You are a Python code analyst, evaluating scripts for potential improvements. |
Sets the line width to the closest supported one
| Here you have a function in Python 3, explain what it does
def _set_closest_stroke_width(self, width):
# Adapt line width to zooming level
width *= self.pixel_to_size_ratio() / 6.
stroke_width_range = glGetFloatv(GL_LINE_WIDTH_RANGE)
stroke_width_granularity = glGetFloatv(GL_LINE_WIDTH_... | You are a Python code generator, capable of creating scripts from specifications. |
Draws a circle with a desired position with desired size. | Here you have a function in Python 3, explain what it does
def _draw_circle(self, pos_x, pos_y, radius, depth, stroke_width=1., fill_color=None, border_color=None,
from_angle=0., to_angle=2 * pi):
"""Draws a circle
Draws a circle with a line segment a desired position with desired ... | You are a Python code generator, capable of creating scripts from specifications. |
Apply orthogonal view to the current view | Given the following Python 3 function, write the documentation
def _apply_orthogonal_view(self):
left, right, bottom, top = self.get_view_coordinates()
glOrtho(left, right, bottom, top, -10, 0) | As a python code expert, you are capable of creating scripts from specifications. |
def tsam_cluster(timeseries_df, typical_periods=10, how='daily'):
"""
Parameters
----------
df : pd.DataFrame
DataFrame with timeseries to cluster
Returns
-------
timeseries : pd.DataFrame
Clustered timeseries
"""
if how == 'daily':
hours = 24
if how == ... | How would you code a function in Python 3 to
cluster the time series with the same number of hours and cluster_weights. | You are a Python code generator, capable of creating scripts from specifications. |
def update_data_frames(network, cluster_weights, dates, hours):
""" Updates the snapshots, snapshots weights and the dataframes based on
the original data in the network and the medoids created by clustering
these original data.
Parameters
-----------
network : pyPSA network object
cluster_... | Write a Python 3 function that can
update the snapshots weights and dataframes based on the original data in the network and the medoids created by clustering . | As a python code expert, you are capable of creating scripts from specifications. |
def setup_installation():
"""Install necessary GUI resources
By default, RAFCON should be installed via `setup.py` (`pip install rafcon`). Thereby, all resources are being
installed. However, if this is not the case, one can set the `RAFCON_CHECK_INSTALLATION` env variable to `True`.
Then, the in... | Can you implement a function in Python 3 that
installs necessary GUI resources By default, RAFCON should be installed via `setup.py` (`pip install rafcon`). Thereby, all resources are being installed. However, if this is not the case, one can set the `RAFCON_CHECK_INSTALLATION` env variable to `True`. Then, the install... | As a Python code analyst, you investigate and solve complex coding mysteries |
def setup_argument_parser():
"""Sets up teh parser with the required arguments
:return: The parser object
"""
default_config_path = filesystem.get_default_config_path()
filesystem.create_path(default_config_path)
parser = core_singletons.argument_parser
parser.add_argument('-n', '--new', a... | Create a Python 3 function for
setting up the argument parser with the required arguments | As a python code expert, you are capable of creating scripts from specifications. |
def register_view(self, view):
"""Called when the View was registered"""
super(ScopedVariableListController, self).register_view(view)
view['name_col'].add_attribute(view['name_text'], 'text', self.NAME_STORAGE_ID)
if not isinstance(self.model.state, LibraryState) and self.model.state.g... | Write a Python 3 function that can
call when the View was registered | You are a Python code generator, capable of creating scripts from specifications. |
Register callback methods for triggered actions
| How would you explain what the following Python 3 function does
def register_actions(self, shortcut_manager):
shortcut_manager.add_callback_for_action("delete", self.remove_action_callback)
shortcut_manager.add_callback_for_action("add", self.add_action_callback)
shortcut_manager.add_callback_fo... | You are a Python code architect, reviewing and designing scalable and efficient code |
Callback method for paste action | Can you generate a brief explanation for the following Python 3 code
def paste_action_callback(self, *event):
if react_to_event(self.view, self.tree_view, event) and self.active_entry_widget is None:
if not global_clipboard.model_copies["scoped_variables"] and \
(global_clipboard... | You are a Python code generator, capable of creating scripts from specifications. |
def on_add(self, widget, data=None):
"""Create a new scoped variable with default values"""
if isinstance(self.model, ContainerStateModel):
try:
scoped_var_ids = gui_helper_state_machine.add_scoped_variable_to_selected_states(selected_states=[self.model])
if s... | Implement a function in Python 3 to
create a new scoped variable with default values | As a Python code composer, you craft elegant and concise scripts. |
def remove_core_element(self, model):
"""Remove respective core element of handed scoped variable model
:param ScopedVariableModel model: Scoped variable model which core element should be removed
:return:
"""
assert model.scoped_variable.parent is self.model.state
gui_h... | Can you create a Python 3 function that
removes respective core element of handed scoped variable model | As a Python code analyst, you investigate and solve complex coding mysteries |
def apply_new_scoped_variable_name(self, path, new_name):
"""Applies the new name of the scoped variable defined by path
:param str path: The path identifying the edited variable
:param str new_name: New name
"""
data_port_id = self.list_store[path][self.ID_STORAGE_ID]
t... | Can you create a Python 3 function that
applies the new name of the scoped variable defined by path to the new name. | You are a Python code architect, reviewing and designing scalable and efficient code |
Applies the new data type of the scoped variable defined by path | Explain what the following Python 3 code does
def apply_new_scoped_variable_type(self, path, new_variable_type_str):
data_port_id = self.list_store[path][self.ID_STORAGE_ID]
try:
if self.model.state.scoped_variables[data_port_id].data_type.__name__ != new_variable_type_str:
s... | As a Python code analyst, you investigate and solve complex coding mysteries |
def apply_new_scoped_variable_default_value(self, path, new_default_value_str):
"""Applies the new default value of the scoped variable defined by path
:param str path: The path identifying the edited variable
:param str new_default_value_str: New default value as string
"""
dat... | Create a Python 3 function to
apply the new default value of the scoped variable defined by path | As a Python code composer, you craft elegant and concise scripts. |
def reload_scoped_variables_list_store(self):
"""Reloads the scoped variable list store from the data port models"""
if isinstance(self.model, ContainerStateModel):
tmp = self.get_new_list_store()
for sv_model in self.model.scoped_variables:
data_type = sv_model.... | Write a Python 3 function that can
reload the scoped variable list store from the data port models | You are a Python code generator, capable of creating scripts from specifications. |
def store_session():
""" Stores reference backup information for all open tabs into runtime config
The backup of never stored tabs (state machines) and not stored state machine changes will be triggered a last
time to secure data lose.
"""
from rafcon.gui.singleton import state_machine_manager_mode... | Write a Python 3 function that can
store reference backup information for all open tabs into runtime config | You are a Python code architect, reviewing and designing scalable and efficient code |
Restore stored tabs from runtime config | Explain what the following Python 3 code does
def restore_session_from_runtime_config():
# TODO add a dirty lock for a crashed rafcon instance also into backup session feature
# TODO in case a dialog is needed to give the user control
# TODO combine this and auto-backup in one structure/controller/observer
... | You are a Python code generator, capable of creating scripts from specifications. |
Add a new logging level to the logging module and the currently configured logging class. | Make a summary of the following Python 3 code
def add_logging_level(level_name, level_num, method_name=None):
if not method_name:
method_name = level_name.lower()
if hasattr(logging, level_name):
raise AttributeError('{} already defined in logging module'.format(level_name))
if hasattr(logg... | As a Python code analyst, you investigate and solve complex coding mysteries |
Returns a logger object with the given name | Can you generate a brief explanation for the following Python 3 code
def get_logger(name):
if name in existing_loggers:
return existing_loggers[name]
# Ensure that all logger are within the RAFCON root namespace
namespace = name if name.startswith(rafcon_root + ".") else rafcon_root + "." + name
... | As a Python code composer, you craft elegant and concise scripts. |
def open_state_machine(path=None, recent_opened_notification=False):
""" Open a state machine from respective file system path
:param str path: file system path to the state machine
:param bool recent_opened_notification: flags that indicates that this call also should update recently open
:rtype rafc... | Can you implement a function in Python 3 that
opens a state machine from respective file system path. | You are a Python code analyst, evaluating scripts for potential improvements. |
Save selected state machine | Given the following Python 3 function, write the documentation
def save_state_machine(delete_old_state_machine=False, recent_opened_notification=False, as_copy=False, copy_path=None):
state_machine_manager_model = rafcon.gui.singleton.state_machine_manager_model
states_editor_ctrl = rafcon.gui.singleton.main_w... | As a python code expert, you are capable of creating scripts from specifications. |
Saves the selected state machine to path | Given the following Python 3 function, write the documentation
def save_state_machine_as(path=None, recent_opened_notification=False, as_copy=False):
state_machine_manager_model = rafcon.gui.singleton.state_machine_manager_model
selected_state_machine_model = state_machine_manager_model.get_selected_state_mach... | You are a Python code architect, reviewing and designing scalable and efficient code |
def save_selected_state_as():
"""Save selected state as separate state machine
:return True if successfully stored, False if the storing process was canceled or stopped by condition fail
:rtype bool:
:raises exceptions.ValueError: If dialog response ids are out of bounds
"""
state_machine_mana... | How would you code a function in Python 3 to
save selected state as separate state machine | As a Python code analyst, you investigate and solve complex coding mysteries |
Checks if a specific state machine is stopped and in case request user by dialog window how to proceed
| Here you have a function in Python 3, explain what it does
def is_state_machine_stopped_to_proceed(selected_sm_id=None, root_window=None):
# check if the/a state machine is still running
if not state_machine_execution_engine.finished_or_stopped():
if selected_sm_id is None or selected_sm_id == state_mac... | You are a Python code analyst, evaluating scripts for potential improvements. |
Reloads the currently selected state machine. | Explain what the following Python 3 code does
def refresh_selected_state_machine():
selected_sm_id = rafcon.gui.singleton.state_machine_manager_model.selected_state_machine_id
selected_sm = state_machine_manager.state_machines[selected_sm_id]
state_machines_editor_ctrl = rafcon.gui.singleton.main_window_co... | As a Python code composer, you craft elegant and concise scripts. |
Remove all libraries and state machines and reloads them freshly from the file system | Can you generate the documentation for the following Python 3 function
def refresh_all(force=False):
state_machines_editor_ctrl = rafcon.gui.singleton.main_window_controller.get_controller('state_machines_editor_ctrl')
states_editor_ctrl = rafcon.gui.singleton.main_window_controller.get_controller('states_edito... | As a Python code translator, you convert algorithms and pseudocode into Python. |
Deletes the respective core element of handed model of state machine. | Can you tell what is the following Python 3 function doing
def delete_core_element_of_model(model, raise_exceptions=False, recursive=True, destroy=True, force=False):
if isinstance(model, AbstractStateModel) and model.state.is_root_state:
logger.warning("Deletion is not allowed. {0} is root state of state m... | As a Python code analyst, you investigate and solve complex coding mysteries |
def delete_core_elements_of_models(models, raise_exceptions=True, recursive=True, destroy=True, force=False):
"""Deletes all respective core elements for the given models
Calls the :func:`delete_core_element_of_model` for all given models.
:param models: A single model or a list of models of respective co... | Implement a function in Python 3 to
delete all respective core elements for the given models. | As a Python code analyst, you investigate and solve complex coding mysteries |
Checks if selected elements are inside of library state | Can you generate a brief explanation for the following Python 3 code
def is_selection_inside_of_library_state(state_machine_m=None, selected_elements=None):
if state_machine_m is None:
state_machine_m = rafcon.gui.singleton.state_machine_manager_model.get_selected_state_machine_model()
if state_machine_... | As a Python code analyst, you investigate and solve complex coding mysteries |
def add_new_state(state_machine_m, state_type):
"""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 parent state (selected state) is a container state, and if the graphical editor or
the state machine tree are in focus.
... | Can you create a Python 3 function that
triggers when the Add State button is pressed. | As a Python code composer, you craft elegant and concise scripts. |
Adds a state into the selected state | Explain what the following Python 3 code does
def insert_state_into_selected_state(state, as_template=False):
smm_m = rafcon.gui.singleton.state_machine_manager_model
if not isinstance(state, State):
logger.warning("A state is needed to be insert not {0}".format(state))
return False
if not... | You are a Python code architect, reviewing and designing scalable and efficient code |
Substitute the selected state with the handed state | Can you tell what is the following Python 3 function doing
def substitute_selected_state(state, as_template=False, keep_name=False):
# print("substitute_selected_state", state, as_template)
assert isinstance(state, State)
from rafcon.core.states.barrier_concurrency_state import DeciderState
if isinstanc... | As a python code expert, you are capable of creating scripts from specifications. |
Construct a partial network that has been merged into a single cluster. | Make a summary of the following Python 3 code
def construct_partial_network(self, cluster, scenario):
#Create an empty network
partial_network = Network()
# find all lines that have at least one bus inside the cluster
busflags = (self.buses['cluster'] == cluster)
def is_bus_in... | You are a Python code architect, reviewing and designing scalable and efficient code |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.