From 0887677f1356c3f5fc55761d314ce692eb57a007 Mon Sep 17 00:00:00 2001 From: juliettelavoie Date: Mon, 6 Jan 2025 18:09:56 -0500 Subject: [PATCH] order --- src/xclim/ensembles/_partitioning.py | 4 +++- tests/test_partitioning.py | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/xclim/ensembles/_partitioning.py b/src/xclim/ensembles/_partitioning.py index 00582714b..549819642 100644 --- a/src/xclim/ensembles/_partitioning.py +++ b/src/xclim/ensembles/_partitioning.py @@ -422,7 +422,9 @@ def general_partition( # Mean projection: # This is not part of the original algorithm, # but we want all partition algos to have similar outputs. - g = sm.mean(dim=all_types) + g = sm.mean(dim=all_types[0]) + for dim in all_types[1:]: + g = g.mean(dim=dim) return g, uncertainty diff --git a/tests/test_partitioning.py b/tests/test_partitioning.py index 100cef5c6..64bcb2c7c 100644 --- a/tests/test_partitioning.py +++ b/tests/test_partitioning.py @@ -171,6 +171,11 @@ def test_general_partition(lafferty_sriver_ds): var_first=["model", "downscaling"], mean_first=["scenario"], weights=["model", "downscaling"], + sm="poly", + ) + # fix order + u2 = u2.sel( + uncertainty=["model", "scenario", "downscaling", "variability", "total"] ) assert u1.equals(u2)