#14772 Python: GridCaseGroup.compute_statistics() treats an empty case_ids list as all cases

The legacy computeCaseGroupStatistics command could not distinguish an unset list from an
empty one, so [] meant all statistics cases. Keep that in the deprecation shim.
This commit is contained in:
Kristian Bendiksen committed 2026-09-22 14:19:23 +02:00
1 parent 0eff2c193a
commit fed0fa43c7
2 files changed
+11 -2

No files matched your search

+2 -2
View File
@@ -64,7 +64,7 @@ def compute_statistics(self, case_ids=None):
statistics case (see statistics_cases()) instead.
Arguments:
case_ids(list of integers): List of case ids. If this is None all cases in group are included
case_ids(list of integers): List of case ids. If this is None or empty all cases in group are included
"""
warnings.warn(
@@ -73,5 +73,5 @@ def compute_statistics(self, case_ids=None):
stacklevel=3,
)
for statistics_case in self.statistics_cases():
if case_ids is None or statistics_case.id in case_ids:
if not case_ids or statistics_case.id in case_ids:
statistics_case.compute_statistics(update_views=True)
@@ -100,6 +100,15 @@ def test_statistics_case_object_methods(rips_instance, initialize_test):
with pytest.warns(DeprecationWarning):
grid_case_group.compute_statistics(case_ids=[stat_case.id])
# An empty list means all statistics cases in the group, as in the legacy command
empty_case = grid_case_group.create_statistics_case(populate_result_selection=False)
empty_case.set_source_properties("DYNAMIC_NATIVE", ["SWAT"])
with pytest.warns(DeprecationWarning):
grid_case_group.compute_statistics(case_ids=[])
assert "SWAT_MEAN" in empty_case.available_properties(
rips.PropertyType.DYNAMIC_NATIVE
)
def test_replace_source_cases(rips_instance, initialize_test):
case_paths = [