Skip to content

Commit d11e7b6

Browse files
authored
New _ReducedFlowSystemBuilder class (lines 82-381): (#593)
_ReducedFlowSystemBuilder ├── __init__(fs, aggregation_results, timesteps_per_cluster, dt, dim_names) │ └── Pre-computes: n_clusters, is_segmented, cluster_coords, time_coords, base_coords ├── _expand_and_combine() # Shared pattern: expand_dims → combine_slices ├── build_cluster_weights() # Extract weights from results ├── build_typical_periods() # Extract and reshape cluster representatives ├── build_segment_durations() # Extract segment durations (if segmented) ├── build_metrics() # Extract RMSE/MAE metrics ├── build_reduced_dataset() # Assemble variables into Dataset └── build() # Main entry: orchestrates all builders → FlowSystem Call sites updated: - cluster() → _ReducedFlowSystemBuilder(fs, ...).build(ds) - apply_clustering() → _ReducedFlowSystemBuilder(fs, ...).build(ds) Deleted from TransformAccessor (~360 lines): - _accuracy_to_dataframe() (moved to module-level) - _build_cluster_weight_da() - _build_typical_das() - _build_segment_durations_da() - _build_clustering_metrics() - _build_reduced_flow_system() - _build_reduced_dataset() Benefits: - Coordinates computed once in __init__, not passed to every method - Common _expand_and_combine() pattern extracted (was repeated 4x) - Clear single entry point: builder.build(ds) - Each build method independently testable - TransformAccessor significantly simplified
1 parent f9c6ff0 commit d11e7b6

1 file changed

Lines changed: 317 additions & 375 deletions

File tree

0 commit comments

Comments
 (0)