From 1c9e4bd8b5de80c90162e232931f5aa00fdf92c6 Mon Sep 17 00:00:00 2001 From: Michele Simionato Date: Thu, 7 Nov 2024 10:02:13 +0100 Subject: [PATCH] Fixed extract_agg_damages --- openquake/calculators/extract.py | 8 ++++++-- openquake/calculators/tests/scenario_damage_test.py | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/openquake/calculators/extract.py b/openquake/calculators/extract.py index ef2d7a950e3..501e63072bd 100644 --- a/openquake/calculators/extract.py +++ b/openquake/calculators/extract.py @@ -852,8 +852,12 @@ def extract_agg_damages(dstore, what): number of damage states, or an array of length 0 if there is no data for the given tags """ - loss_type, what = what.rsplit('?', 1) # loss_type in mandatory - tags = what.split('&') if what else [] + if '?' in what: + loss_type, what = what.rsplit('?', 1) + tags = what.split('&') if what else [] + else: + loss_type = what + tags = [] if 'damages-rlzs' in dstore: oq = dstore['oqparam'] li = oq.lti[loss_type] diff --git a/openquake/calculators/tests/scenario_damage_test.py b/openquake/calculators/tests/scenario_damage_test.py index c4af7d138da..bf34d84ac6e 100644 --- a/openquake/calculators/tests/scenario_damage_test.py +++ b/openquake/calculators/tests/scenario_damage_test.py @@ -88,7 +88,7 @@ def test_case_1c(self): delta=1E-5) # check agg_damages extraction - total = extract(self.calc.datastore, 'agg_damages/structural?') + total = extract(self.calc.datastore, 'agg_damages/structural') aac(total, [[27652.219, 28132.8, 9511.933, 2870.9312, 11832.913]], atol=.1)