Skip to content

Commit cf0caf4

Browse files
FBumannclaude
andauthored
refactor!: remove ClusteringPlotAccessor, metrics, original_data, include_original_data (#655)
BREAKING CHANGES: - Remove ClusteringPlotAccessor (compare, heatmap, clusters methods) - Remove original_data and aggregated_data from Clustering - Remove _metrics from Clustering (use aggregation_result.accuracy instead) - Remove include_original_data parameter from to_dataset/to_netcdf - Simplify _create_reference_structure to just serialize ClusteringResult dict - Remove build_metrics from _ReducedFlowSystemBuilder Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 086a450 commit cf0caf4

7 files changed

Lines changed: 22 additions & 657 deletions

File tree

flixopt/clustering/__init__.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
77
Example usage:
88
9-
# Cluster a FlowSystem to reduce timesteps
109
from tsam import ExtremeConfig
1110
1211
fs_clustered = flow_system.transform.cluster(
@@ -15,21 +14,14 @@
1514
extremes=ExtremeConfig(method='new_cluster', max_value=['Demand|fixed_relative_profile']),
1615
)
1716
18-
# Access clustering structure (available before AND after IO)
1917
clustering = fs_clustered.clustering
2018
print(f'Number of clusters: {clustering.n_clusters}')
21-
print(f'Clustering info: {clustering.clustering_result}') # tsam_xarray ClusteringResult
19+
print(f'Clustering result: {clustering.clustering_result}')
2220
23-
# Access tsam_xarray AggregationResult for detailed analysis
24-
# NOTE: Only available BEFORE saving/loading. Lost after IO.
21+
# Access tsam_xarray AggregationResult (only before saving/loading)
2522
result = clustering.aggregation_result
26-
result.cluster_representatives # DataArray with aggregated time series
27-
result.accuracy # AccuracyMetrics (rmse, mae)
28-
29-
# Save and load - structure preserved, AggregationResult access lost
30-
fs_clustered.to_netcdf('system.nc')
31-
# Use include_original_data=False for smaller files (~38% reduction)
32-
fs_clustered.to_netcdf('system.nc', include_original_data=False)
23+
result.cluster_representatives # DataArray
24+
result.accuracy # AccuracyMetrics
3325
3426
# Expand back to full resolution
3527
fs_expanded = fs_clustered.transform.expand()

0 commit comments

Comments
 (0)