spinetoolbox.spine_db_editor.widgets.scenario_generator
Contains a dialog for generating scenarios from selected alternatives.
Module Contents
Classes
Generic enumeration. |
|
A dialog where users can generate scenarios from given alternatives. |
Functions
|
Removes duplicate scenario alternatives. |
|
Returns the name of a 'base' alternative or empty string if not found. |
|
Returns a formattable string with enough zero padding to hold item_count digits. |
- class spinetoolbox.spine_db_editor.widgets.scenario_generator._ScenarioNameResolution[source]
Bases:
enum.Enum
Generic enumeration.
Derive from this class to define new enumerations.
- class spinetoolbox.spine_db_editor.widgets.scenario_generator.ScenarioGenerator(parent, db_map, alternatives, spine_db_editor)[source]
Bases:
PySide6.QtWidgets.QWidget
A dialog where users can generate scenarios from given alternatives.
- Parameters
parent (QWidget) – parent widget
db_map (DiffDatabaseMapping) – database mapping that contains the alternatives
alternatives (Iterable of CacheItem) – alternatives from which the scenarios are generated
spine_db_editor (SpineDBEditor) – database editor instance
- accept()[source]
Generates scenarios and closes the dialog.
The operation may get cancelled by user if there are conflicts in scenario names.
- _generate_scenarios(new_scenarios, scenarios_to_modify, scenario_alternatives)[source]
Generates scenarios with all possible combinations of given alternatives.
- Parameters
new_scenarios (Iterable of str) – names of new scenarios to create
scenarios_to_modify (Iterable of str) – names of scenarios to modify
scenario_alternatives (list of list) – alternative items for each scenario
- _check_existing_scenarios(proposed_scenario_names, existing_scenario_names)[source]
Checks if proposed scenarios exist, and if so, prompts users what to do.
- Parameters
proposed_scenario_names (Iterable of str) – proposed scenario names
existing_scenario_names (set of str) – existing scenario names
- Returns
action to take
- Return type
- spinetoolbox.spine_db_editor.widgets.scenario_generator._ensure_unique(scenario_alternatives)[source]
Removes duplicate scenario alternatives.
- Parameters
scenario_alternatives (list of list) – scenario alternatives
- spinetoolbox.spine_db_editor.widgets.scenario_generator._find_base_alternative(names)[source]
Returns the name of a ‘base’ alternative or empty string if not found.
Basically, checks if “Base” is in names, otherwise searches for the first case-insensitive version of “base”.
- Parameters
names (list of str) – alternative names
- Returns
base alternative name
- Return type
str
- spinetoolbox.spine_db_editor.widgets.scenario_generator._suffix(item_count)[source]
Returns a formattable string with enough zero padding to hold item_count digits.
- Parameters
item_count (int) – maximum number of items
- Returns
string in the form ‘{:0n}’ where n is the number of digits in item_count
- Return type
str