ComparisonTab package
Variant comparison module for district heating project analysis.
Provides automatic variant discovery, KPI dashboards, and comparative visualization of economic and technical metrics.
- author:
Dipl.-Ing. (FH) Jonas Pfeiffer
- districtheatingsim.gui.ComparisonTab.comparison_tab.format_kpi_range(variant_data: list[dict], key: str, fmt: str, *, empty: str = '--') str[source]
Summarize one KPI across the compared variants for the dashboard.
Filters out missing / zero values, then returns a single formatted number, a
"min - max"range when several variants differ, oremptywhen no variant provides the value. GUI-free domain/formatting logic (extracted from the view so it is unit-testable — BACKLOG B2).- Parameters:
variant_data – One result dict per variant.
key – The metric key to read from each variant dict.
fmt – A
format()spec applied to each number (e.g.".1f").empty – Text to show when no variant provides the metric.
- Returns:
The formatted value / range /
emptystring.- Return type:
- class districtheatingsim.gui.ComparisonTab.comparison_tab.ProjectExplorer(folder_manager, config_manager, parent=None)[source]
Bases:
QWidgetProject explorer for automatic variant discovery and selection.
Scans project folder for available variants and allows multi-selection for comparison analysis.
- variants_changed
int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- Type:
pyqtSignal(*types, name
- Type:
str = …, revision
- set_base_path(base_path)[source]
Set base path and refresh project list.
- Parameters:
base_path (str) – Project data base path
- discover_projects()[source]
Discover variants and their energy system configs; build two-level tree.
Top level: variant folders (
Variante *). Children: eachErgebnisse*.jsonconfig inside that variant.
- validate_variant(variant_path)[source]
Validate that a variant has at least one energy system result file.
- class districtheatingsim.gui.ComparisonTab.comparison_tab.ComparisonDashboard(parent=None)[source]
Bases:
QWidgetDashboard widget showing comparison overview and KPIs.
Displays economic, environmental, and technical metrics across selected variants with interactive charts.
- class districtheatingsim.gui.ComparisonTab.comparison_tab.ComparisonTab(folder_manager, data_manager, config_manager, parent=None)[source]
Bases:
QWidgetComparison tab with comprehensive variant analysis.
Integrates project explorer, KPI dashboard, and comparative visualizations for multi-variant evaluation.
- __init__(folder_manager, data_manager, config_manager, parent=None)[source]
Initialize comparison tab.
- Parameters:
folder_manager (ProjectFolderManager) – Project folder manager
data_manager (DataManager) – Application data manager
config_manager (ProjectConfigManager) – Configuration manager
parent (QWidget) – Parent widget (optional)
- create_comparison_content()[source]
Create main comparison content area.
- Returns:
Content widget with dashboard tabs
- Return type:
QWidget
- on_variants_changed(selected_variants)[source]
Handle variant selection changes from explorer.
- Parameters:
selected_variants (list) – List of selected variant info dicts
- load_variant_data(selected_variants)[source]
Load data for selected (variant, config) combinations.
Network KPIs are cached per variant path since they are shared across configs.
- Parameters:
selected_variants (list) – List of item data dicts from ProjectExplorer
- process_variant_results(results)[source]
Process raw variant results for comparison.
- Parameters:
results (dict) – Raw results from JSON file
- Returns:
Processed results for dashboard display
- Return type:
- Raises:
ValueError – If processing fails