sentence1 stringlengths 52 3.87M | sentence2 stringlengths 1 47.2k | label stringclasses 1
value |
|---|---|---|
def selection_notification(self, model, property, info):
"""If a single state is selected, open the corresponding tab"""
if model is not self.current_state_machine_m or len(self.current_state_machine_m.ongoing_complex_actions) > 0:
return
state_machine_m = model
assert isinst... | If a single state is selected, open the corresponding tab | entailment |
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... | Checks whether the name of a state was changed and change the tab label accordingly | entailment |
def update_tab_label(self, state_m):
"""Update all tab labels
:param rafcon.state_machine.states.state.State state_m: State model who's tab label is to be updated
"""
state_identifier = self.get_state_identifier(state_m)
if state_identifier not in self.tabs and state_identifier ... | Update all tab labels
:param rafcon.state_machine.states.state.State state_m: State model who's tab label is to be updated | entailment |
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 | Return the state identifier for a given page | entailment |
def rename_selected_state(self, key_value, modifier_mask):
"""Callback method for shortcut action rename
Searches for a single selected state model and open the according page. Page is created if it is not
existing. Then the rename method of the state controller is called.
:param key_v... | Callback method for shortcut action rename
Searches for a single selected state model and open the according page. Page is created if it is not
existing. Then the rename method of the state controller is called.
:param key_value:
:param modifier_mask: | entailment |
def generate_semantic_data_key(used_semantic_keys):
""" Create a new and unique semantic data key
:param list used_semantic_keys: Handed list of keys already in use
:rtype: str
:return: semantic_data_id
"""
semantic_data_id_counter = -1
while True:
semantic_data_id_counter += 1
... | Create a new and unique semantic data key
:param list used_semantic_keys: Handed list of keys already in use
:rtype: str
:return: semantic_data_id | entailment |
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... | 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.
:param size: the length of the generated keys
:param chars: the set of characters a sample draws from
... | entailment |
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... | 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 size: the length of the generated keys
:param chars: the set of characters a s... | entailment |
def set(self):
"""Set the color as current OpenGL color
"""
glColor4f(self.r, self.g, self.b, self.a) | Set the color as current OpenGL color | entailment |
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... | 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. | entailment |
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... | 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 | entailment |
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.... | Process the drawing routine | entailment |
def expose_finish(self, *args):
"""Finish drawing process
"""
# Obtain a reference to the OpenGL drawable
# and rendering context.
gldrawable = self.get_gl_drawable()
# glcontext = self.get_gl_context()
if not gldrawable:
return
# Put the buf... | Finish drawing process | entailment |
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 ... | Draw 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 state ... | entailment |
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... | 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 waypoints:... | entailment |
def _write_string(self, string, pos_x, pos_y, height, color, bold=False, align_right=False, depth=0.):
"""Write a string
Writes a string with a simple OpenGL method in the given size at the given position.
:param string: The string to draw
:param pos_x: x starting position
:par... | Write a string
Writes a string with a simple OpenGL method in the given size at the given position.
:param string: The string to draw
:param pos_x: x starting position
:param pos_y: y starting position
:param height: desired height
:param bold: flag whether to use a bol... | entailment |
def prepare_selection(self, pos_x, pos_y, width, height):
"""Prepares the selection rendering
In order to find out the object being clicked on, the scene has to be rendered again around the clicked position
:param pos_x: x coordinate
:param pos_y: y coordinate
"""
glSel... | Prepares the selection rendering
In order to find out the object being clicked on, the scene has to be rendered again around the clicked position
:param pos_x: x coordinate
:param pos_y: y coordinate | entailment |
def find_selection():
"""Finds the selected ids
After the scene has been rendered again in selection mode, this method gathers and returns the ids of the
selected object and restores the matrices.
:return: The selection stack
"""
hits = glRenderMode(GL_RENDER)
... | Finds the selected ids
After the scene has been rendered again in selection mode, this method gathers and returns the ids of the
selected object and restores the matrices.
:return: The selection stack | entailment |
def _set_closest_stroke_width(self, width):
"""Sets the line width to the closest supported one
Not all line widths are supported. This function queries both minimum and maximum as well as the step size of
the line width and calculates the width, which is closest to the given one. This width is... | Sets the line width to the closest supported one
Not all line widths are supported. This function queries both minimum and maximum as well as the step size of
the line width and calculates the width, which is closest to the given one. This width is then set.
:param width: The desired line widt... | entailment |
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 size.
:param float pos_x: Center x position
... | Draws a circle
Draws a circle with a line segment a desired position with desired size.
:param float pos_x: Center x position
:param float pos_y: Center y position
:param float depth: The Z layer
:param float radius: Radius of the circle | entailment |
def _apply_orthogonal_view(self):
"""Orthogonal view with respect to current aspect ratio
"""
left, right, bottom, top = self.get_view_coordinates()
glOrtho(left, right, bottom, top, -10, 0) | Orthogonal view with respect to current aspect ratio | entailment |
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 == ... | Parameters
----------
df : pd.DataFrame
DataFrame with timeseries to cluster
Returns
-------
timeseries : pd.DataFrame
Clustered timeseries | entailment |
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_... | 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_weights: dictionary
dates: Datetimeindex
Returns
-------
... | entailment |
def daily_bounds(network, snapshots):
""" This will bound the storage level to 0.5 max_level every 24th hour.
"""
sus = network.storage_units
# take every first hour of the clustered days
network.model.period_starts = network.snapshot_weightings.index[0::24]
network.model.storages = sus.index
... | This will bound the storage level to 0.5 max_level every 24th hour. | entailment |
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... | 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 installation will be performed befo... | entailment |
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... | Sets up teh parser with the required arguments
:return: The parser object | entailment |
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... | 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 paste_action_callback(self, *event):
"""Callback method for paste action
The method trigger the clipboard paste of the list of scoped variables in the clipboard or in case this list is
empty and there are other port types selected in the clipboard it will trigger the paste with convert fl... | Callback method for paste action
The method trigger the clipboard paste of the list of scoped variables in the clipboard or in case this list is
empty and there are other port types selected in the clipboard it will trigger the paste with convert flag.
The convert flag will cause the inserti... | entailment |
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... | Create a new scoped variable with default values | entailment |
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... | Remove respective core element of handed scoped variable model
:param ScopedVariableModel model: Scoped variable model which core element should be removed
:return: | entailment |
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... | 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 | entailment |
def apply_new_scoped_variable_type(self, path, new_variable_type_str):
"""Applies the new data type of the scoped variable defined by path
:param str path: The path identifying the edited variable
:param str new_variable_type_str: New data type as str
"""
data_port_id = self.lis... | Applies the new data type of the scoped variable defined by path
:param str path: The path identifying the edited variable
:param str new_variable_type_str: New data type as str | entailment |
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... | 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 | entailment |
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.... | Reloads the scoped variable list store from the data port models | entailment |
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... | 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. | entailment |
def restore_session_from_runtime_config():
""" Restore stored tabs from runtime config
The method checks if the last status of a state machine is in the backup or in tis original path and loads it
from there. The original path of these state machines are also insert into the recently opened state machines
... | Restore stored tabs from runtime config
The method checks if the last status of a state machine is in the backup or in tis original path and loads it
from there. The original path of these state machines are also insert into the recently opened state machines
list. | entailment |
def add_logging_level(level_name, level_num, method_name=None):
"""Add new logging level
Comprehensively adds a new logging level to the `logging` module and the currently configured logging class.
`method_name` becomes a convenience method for both `logging` itself and the class returned by
`logging.... | Add new logging level
Comprehensively adds a new logging level to the `logging` module and the currently configured logging class.
`method_name` becomes a convenience method for both `logging` itself and the class returned by
`logging.getLoggerClass()` (usually just `logging.Logger`). If `method_name` is ... | entailment |
def get_logger(name):
"""Returns a logger for the given name
The function is basically a wrapper for logging.getLogger and only ensures that the namespace is within "rafcon."
and that the propagation is enabled.
:param str name: The namespace of the new logger
:return: Logger object with given nam... | Returns a logger for the given name
The function is basically a wrapper for logging.getLogger and only ensures that the namespace is within "rafcon."
and that the propagation is enabled.
:param str name: The namespace of the new logger
:return: Logger object with given namespace
:rtype: logging.Lo... | entailment |
def etrago(args):
"""The etrago function works with following arguments:
Parameters
----------
db : str
``'oedb'``,
Name of Database session setting stored in *config.ini* of *.egoio*
gridversion : NoneType or str
``'v0.2.11'``,
Name of the data version number of ... | The etrago function works with following arguments:
Parameters
----------
db : str
``'oedb'``,
Name of Database session setting stored in *config.ini* of *.egoio*
gridversion : NoneType or str
``'v0.2.11'``,
Name of the data version number of oedb: state ``'None'`` fo... | entailment |
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... | 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 rafcon.core.state_machine.StateMachine
:return: opened state machine | entailment |
def save_state_machine(delete_old_state_machine=False, recent_opened_notification=False, as_copy=False, copy_path=None):
""" Save selected state machine
The function checks if states of the state machine has not stored script data abd triggers dialog windows to
take user input how to continue (ignoring o... | Save selected state machine
The function checks if states of the state machine has not stored script data abd triggers dialog windows to
take user input how to continue (ignoring or storing this script changes).
If the state machine file_system_path is None function save_state_machine_as is used to coll... | entailment |
def save_state_machine_as(path=None, recent_opened_notification=False, as_copy=False):
""" Store selected state machine to path
If there is no handed path the interface dialog "create folder" is used to collect one. The state machine finally
is stored by the save_state_machine function.
:param str p... | Store selected state machine to path
If there is no handed path the interface dialog "create folder" is used to collect one. The state machine finally
is stored by the save_state_machine function.
:param str path: Path of state machine folder where selected state machine should be stored
:param bool... | entailment |
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... | 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 | entailment |
def is_state_machine_stopped_to_proceed(selected_sm_id=None, root_window=None):
""" Check if state machine is stopped and in case request user by dialog how to proceed
The function checks if a specific state machine or by default all state machines have stopped or finished
execution. If a state machine i... | Check if state machine is stopped and in case request user by dialog how to proceed
The function checks if a specific state machine or by default all state machines have stopped or finished
execution. If a state machine is still running the user is ask by dialog window if those should be stopped or not.
... | entailment |
def refresh_selected_state_machine():
"""Reloads the 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_wind... | Reloads the selected state machine. | entailment |
def refresh_all(force=False):
"""Remove/close all libraries and state machines and reloads them freshly from the file system
:param bool force: Force flag to avoid any checks
"""
state_machines_editor_ctrl = rafcon.gui.singleton.main_window_controller.get_controller('state_machines_editor_ctrl')
st... | Remove/close all libraries and state machines and reloads them freshly from the file system
:param bool force: Force flag to avoid any checks | entailment |
def delete_core_element_of_model(model, raise_exceptions=False, recursive=True, destroy=True, force=False):
"""Deletes respective core element of handed model of its state machine
If the model is one of state, data flow or transition, it is tried to delete that model together with its
data from the corresp... | Deletes respective core element of handed model of its state machine
If the model is one of state, data flow or transition, it is tried to delete that model together with its
data from the corresponding state machine.
:param model: The model of respective core element to delete
:param bool raise_excep... | entailment |
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... | 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 core element to be deleted
:param bool raise_exceptions: Whether to raise exceptions or log error messages in case ... | entailment |
def is_selection_inside_of_library_state(state_machine_m=None, selected_elements=None):
""" Check if handed or selected elements are inside of library state
If no state machine model or selected_elements are handed the method is searching for the selected state machine and
its selected elements. If selecte... | Check if handed or selected elements are inside of library state
If no state machine model or selected_elements are handed the method is searching for the selected state machine and
its selected elements. If selected_elements list is handed handed state machine model is ignored.
:param rafcon.gui.models.s... | entailment |
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.
... | 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. | entailment |
def insert_state_into_selected_state(state, as_template=False):
"""Adds a State to the selected state
:param state: the state which is inserted
:param as_template: If a state is a library state can be insert as template
:return: boolean: success of the insertion
"""
smm_m = rafcon.gui.singleton... | Adds a State to the selected state
:param state: the state which is inserted
:param as_template: If a state is a library state can be insert as template
:return: boolean: success of the insertion | entailment |
def substitute_selected_state(state, as_template=False, keep_name=False):
""" Substitute the selected state with the handed state
:param rafcon.core.states.state.State state: A state of any functional type that derives from State
:param bool as_template: The flag determines if a handed the state of type Li... | Substitute the selected state with the handed state
:param rafcon.core.states.state.State state: A state of any functional type that derives from State
:param bool as_template: The flag determines if a handed the state of type LibraryState is insert as template
:return: | entailment |
def construct_partial_network(self, cluster, scenario):
"""
Compute the partial network that has been merged into a single cluster.
The resulting network retains the external cluster buses that
share some line with the cluster identified by `cluster`.
These external buses will be... | Compute the partial network that has been merged into a single cluster.
The resulting network retains the external cluster buses that
share some line with the cluster identified by `cluster`.
These external buses will be prefixed by self.id_prefix in order to
prevent name clashes with bu... | entailment |
def solve(self, scenario, solver):
"""
Decompose each cluster into separate units and try to optimize them
separately
:param scenario:
:param solver: Solver that may be used to optimize partial networks
"""
clusters = set(self.clustering.busmap.values)
n =... | Decompose each cluster into separate units and try to optimize them
separately
:param scenario:
:param solver: Solver that may be used to optimize partial networks | entailment |
def modify_origin(self, from_state, from_outcome):
"""Set both from_state and from_outcome at the same time to modify transition origin
:param str from_state: State id of the origin state
:param int from_outcome: Outcome id of the origin port
:raises exceptions.ValueError: If parameters... | Set both from_state and from_outcome at the same time to modify transition origin
:param str from_state: State id of the origin state
:param int from_outcome: Outcome id of the origin port
:raises exceptions.ValueError: If parameters have wrong types or the new transition is not valid | entailment |
def modify_target(self, to_state, to_outcome=None):
"""Set both to_state and to_outcome at the same time to modify transition target
:param str to_state: State id of the target state
:param int to_outcome: Outcome id of the target port
:raises exceptions.ValueError: If parameters have w... | Set both to_state and to_outcome at the same time to modify transition target
:param str to_state: State id of the target state
:param int to_outcome: Outcome id of the target port
:raises exceptions.ValueError: If parameters have wrong types or the new transition is not valid | entailment |
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... | Called when the View was registered | entailment |
def global_variable_is_editable(self, gv_name, intro_message='edit'):
"""Check whether global variable is locked
:param str gv_name: Name of global variable to be checked
:param str intro_message: Message which is used form a useful logger error message if needed
:return:
"""
... | Check whether global variable is locked
:param str gv_name: Name of global variable to be checked
:param str intro_message: Message which is used form a useful logger error message if needed
:return: | entailment |
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... | Create a global variable with default value and select its row
Triggered when the add button in the global variables tab is clicked. | entailment |
def on_lock(self, widget, data=None):
"""Locks respective selected core element"""
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 in path_list] if... | Locks respective selected core element | entailment |
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... | 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: | entailment |
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... | 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 tuple.
:param str new_gv_name: New global variable name | entailment |
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... | 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 row, can be str, int or tuple.
:param str new_value_as_string: New global v... | entailment |
def apply_new_global_variable_type(self, path, new_data_type_as_string):
"""Change global variable value according handed string
Updates the global variable data type only if different.
:param path: The path identifying the edited global variable tree view row, can be str, int or tuple.
... | Change global variable value according handed string
Updates the global variable data type only if different.
:param path: The path identifying the edited global variable tree view row, can be str, int or tuple.
:param str new_data_type_as_string: New global variable data type as string | entailment |
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... | 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 or global variable value changes. | entailment |
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... | Updates the global variable list store
Triggered after creation or deletion of a variable has taken place. | entailment |
def convert_libraries_in_path(config_path, lib_path, target_path=None):
"""
This function resaves all libraries found at the spcified path
:param lib_path: the path to look for libraries
:return:
"""
for lib in os.listdir(lib_path):
if os.path.isdir(os.path.join(lib_path, lib)) and not '... | This function resaves all libraries found at the spcified path
:param lib_path: the path to look for libraries
:return: | entailment |
def get_view_for_id(self, view_class, element_id, parent_item=None):
"""Searches and returns the View for the given id and type
:param view_class: The view type to search for
:param element_id: The id of element of the searched view
:param gaphas.item.Item parent_item: Restrict the sear... | Searches and returns the View for the given id and type
:param view_class: The view type to search for
:param element_id: The id of element of the searched view
:param gaphas.item.Item parent_item: Restrict the search to this parent item
:return: The view for the given id or None if not... | entailment |
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... | Update canvas and handle all events in the gtk queue
:param bool trigger_update: Whether to call update_now() or not | entailment |
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,
... | Return two delegating variables. Each variable should contain
a value attribute with the real value. | entailment |
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... | 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 | entailment |
def convert_string_value_to_type_value(string_value, data_type):
"""Helper function to convert a given string to a given data type
:param str string_value: the string to convert
:param type data_type: the target data type
:return: the converted value
"""
from ast import literal_eval
try:
... | Helper function to convert a given string to a given data type
:param str string_value: the string to convert
:param type data_type: the target data type
:return: the converted value | entailment |
def type_inherits_of_type(inheriting_type, base_type):
"""Checks whether inheriting_type inherits from base_type
:param str inheriting_type:
:param str base_type:
:return: True is base_type is base of inheriting_type
"""
assert isinstance(inheriting_type, type) or isclass(inheriting_type)
a... | Checks whether inheriting_type inherits from base_type
:param str inheriting_type:
:param str base_type:
:return: True is base_type is base of inheriting_type | entailment |
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 BusTResult,\
EgoGridPfHvResultStorage as StorageResult,\
... | Used to clear the result tables in the OEDB. Caution!
This deletes EVERY RESULT SET! | entailment |
def results_to_oedb(session, network, args, grid='hv', safe_results=False):
"""Return results obtained from PyPSA to oedb
Parameters
----------
session:
network : PyPSA network container
Holds topology of grid including results from powerflow analysis
args: dict
Settings from a... | Return results obtained from PyPSA to oedb
Parameters
----------
session:
network : PyPSA network container
Holds topology of grid including results from powerflow analysis
args: dict
Settings from appl.py
grid: str
Choose voltage-level, currently only 'hv' implemented
... | entailment |
def run_sql_script(conn, scriptname='results_md2grid.sql'):
"""This function runs .sql scripts in the folder 'sql_scripts' """
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... | This function runs .sql scripts in the folder 'sql_scripts' | entailment |
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-component (e.g. buses, lines, links).
To connect it to the existing ... | Function that adds an additional network to the existing network container.
The new network can include every PyPSA-component (e.g. buses, lines, links).
To connect it to the existing network, transformers are needed.
All components and its timeseries of the additional scenario need to be insert... | entailment |
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... | 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 fitting 'model_draft.ego_grid_pf_hv_extension_' table.
The scn_n... | entailment |
def distance(x0, x1, y0, y1):
"""
Function that calculates the square of the distance between two points.
Parameters
-----
x0: x - coordinate of point 0
x1: x - coordinate of point 1
y0: y - coordinate of point 0
y1: y - coordinate of point 1
Returns
-----... | Function that calculates the square of the distance between two points.
Parameters
-----
x0: x - coordinate of point 0
x1: x - coordinate of point 1
y0: y - coordinate of point 0
y1: y - coordinate of point 1
Returns
------
distance : float
square ... | entailment |
def calc_nearest_point(bus1, network):
"""
Function that finds the geographical nearest point in a network from a given bus.
Parameters
-----
bus1: float
id of bus
network: Pypsa network container
network including the comparable buses
Returns
------
... | Function that finds the geographical nearest point in a network from a given bus.
Parameters
-----
bus1: float
id of bus
network: Pypsa network container
network including the comparable buses
Returns
------
bus0 : float
bus_id of nearest point | entailment |
def map_ormclass(self, name):
""" Populate _mapped attribute with orm class
Parameters
----------
name : str
Component part of orm class name. Concatenated with _prefix.
"""
try:
self._mapped[name] = getattr(self._pkg, self._prefix + name)
... | Populate _mapped attribute with orm class
Parameters
----------
name : str
Component part of orm class name. Concatenated with _prefix. | entailment |
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(
... | Construct a DateTimeIndex with the queried temporal resolution,
start- and end_snapshot. | entailment |
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... | Construct DataFrame with component data from filtered table data.
Parameters
----------
name : str
Component name.
Returns
-------
pd.DataFrame
Component data. | entailment |
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... | Construct DataFrame with component timeseries data from filtered
table data.
Parameters
----------
name : str
Component name.
column : str
Component field with timevarying data.
Returns
-------
pd.DataFrame
Component d... | entailment |
def build_network(self, network=None, *args, **kwargs):
""" Core method to construct PyPSA Network object.
"""
# 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... | Core method to construct PyPSA Network object. | entailment |
def run(self):
""" This defines the sequence of actions that are taken when the preemptive concurrency state is executed
:return:
"""
logger.debug("Starting execution of {0}{1}".format(self, " (backwards)" if self.backward_execution else ""))
self.setup_run()
try:
... | This defines the sequence of actions that are taken when the preemptive concurrency state is executed
:return: | entailment |
def _check_transition_validity(self, check_transition):
""" Transition of BarrierConcurrencyStates must least fulfill the condition of a ContainerState.
Start transitions are forbidden in the ConcurrencyState
:param check_transition: the transition to check for validity
:return:
... | Transition of BarrierConcurrencyStates must least fulfill the condition of a ContainerState.
Start transitions are forbidden in the ConcurrencyState
:param check_transition: the transition to check for validity
:return: | entailment |
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... | Prepares the model for destruction
Un-registers itself as observer from the state machine and the root state | entailment |
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... | 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: | entailment |
def assign_notification_states_after(self, model, prop_name, info):
"""
This method is called, when any state, transition, data flow, etc. within the state machine modifications. This
then typically requires a redraw of the graphical editor, to display these modifications immediately.
:p... | This method is called, when any state, transition, data flow, etc. within the state machine modifications. This
then typically requires a redraw of the graphical editor, to display these modifications immediately.
:param model: The state machine model
:param prop_name: The property that was chan... | entailment |
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... | Perform fast search from currently active branch to specific version_id and collect all recovery steps. | entailment |
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... | 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 | entailment |
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
... | Highlight buttons according actual execution status. Furthermore it triggers the label redraw of the active
state machine. | entailment |
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... | 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.
Actual pattern is:
* Execution-History is put to focus any time r... | entailment |
def undock_sidebar(self, window_key, widget=None, event=None):
"""Undock/separate sidebar into independent window
The sidebar is undocked and put into a separate new window. The sidebar is hidden in the main-window by
triggering the method on_[widget_name]_hide_clicked(). Triggering this method... | Undock/separate sidebar into independent window
The sidebar is undocked and put into a separate new window. The sidebar is hidden in the main-window by
triggering the method on_[widget_name]_hide_clicked(). Triggering this method shows the
[widget_name]_return_button in the main-window, which d... | entailment |
def redock_sidebar(self, window_key, sidebar_name, controller_name, widget, event=None):
"""Redock/embed sidebar into main window
The size & position of the open window are saved to the runtime_config file, the sidebar is redocked back
to the main-window, and the left-bar window is hidden. The ... | Redock/embed sidebar into main window
The size & position of the open window are saved to the runtime_config file, the sidebar is redocked back
to the main-window, and the left-bar window is hidden. The undock button of the bar is made visible again. | entailment |
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... | 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 GTK notebook where a tab-change occurred
:param page_num: The page number of the currently-selected tab
... | entailment |
def _on_key_press(self, widget, event):
"""Updates the currently pressed keys
In addition, the sidebars are toggled if <Ctrl><Tab> is pressed.
:param Gtk.Widget widget: The main window
:param Gdk.Event event: The key press event
"""
self.currently_pressed_keys.add(event... | Updates the currently pressed keys
In addition, the sidebars are toggled if <Ctrl><Tab> is pressed.
:param Gtk.Widget widget: The main window
:param Gdk.Event event: The key press event | entailment |
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... | Saves current configuration of windows and panes to the runtime config file, before RAFCON is closed. | entailment |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.