From 73cb861483d05e0e977f265aad398d07c64de4fb Mon Sep 17 00:00:00 2001 From: FBumann <117816358+FBumann@users.noreply.github.com> Date: Mon, 27 Jul 2026 18:24:43 +0200 Subject: [PATCH] fix: support tsam_xarray 0.6.5 by using cluster_counts tsam_xarray 0.6.5 renamed AggregationResult.cluster_weights to cluster_counts, keeping the old name as a deprecated property. The `full` extra allows >= 0.6.1, so a fresh install resolves to 0.6.5 and every cluster() call emits a FutureWarning -- and fails outright under -W error, which is how the test suite runs: 254 of 286 clustering tests failed on 0.6.5 before this change. cluster_counts does not exist before 0.6.5, so the floor moves with the rename rather than merely allowing the new version. This shipped in neither 8.0.0 nor its predecessor: #755 carried the same change but was retargeted onto an intermediate branch that merged into main first, so it landed on that branch instead of main. Co-Authored-By: Claude Opus 5 (1M context) --- flixopt/transform_accessor.py | 2 +- pyproject.toml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/flixopt/transform_accessor.py b/flixopt/transform_accessor.py index 30fc12a9d..579d4597b 100644 --- a/flixopt/transform_accessor.py +++ b/flixopt/transform_accessor.py @@ -88,7 +88,7 @@ def build_cluster_weights(self) -> xr.DataArray: Returns: DataArray with dims [cluster, period?, scenario?]. """ - return self._unrename(self._agg_result.cluster_weights.rename('cluster_weight')) + return self._unrename(self._agg_result.cluster_counts.rename('cluster_weight')) def build_typical_periods(self) -> dict[str, xr.DataArray]: """Build typical periods DataArrays with (cluster, time, ...) shape. diff --git a/pyproject.toml b/pyproject.toml index b7bddbfad..347f9b253 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -70,7 +70,7 @@ tutorials = [ # Full feature set (everything except dev tools) full = [ - "tsam_xarray >= 0.6.1, < 1", # Time series aggregation for clustering (wraps tsam); 0.6.1 adds aggregate(cluster_on=) + "tsam_xarray >= 0.6.5, < 1", # Time series aggregation for clustering (wraps tsam); 0.6.5 renames cluster_weights to cluster_counts "tsam >= 3.4.0, < 4", # Directly imported for ClusterConfig, ExtremeConfig, SegmentConfig "pyvis==0.3.2", # Visualizing FlowSystem Network "scipy >= 1.15.1, < 2", # Used by tsam. Prior versions have conflict with highspy. See https://github.com/scipy/scipy/issues/22257 @@ -87,7 +87,7 @@ full = [ # Development tools and testing dev = [ "xarray<2026.8", # TODO: drop once linopy ships xarray 2026.3+ compat fix - "tsam_xarray==0.6.1", # Time series aggregation for clustering (wraps tsam) + "tsam_xarray==0.6.5", # Time series aggregation for clustering (wraps tsam) "tsam==3.4.0", # Directly imported for ClusterConfig, ExtremeConfig, SegmentConfig "pytest==9.1.1", "pytest-xdist==3.8.0",