Skip to content

Commit

Permalink
Fixed extract_agg_damages
Browse files Browse the repository at this point in the history
  • Loading branch information
micheles committed Nov 7, 2024
1 parent 72247bd commit 1c9e4bd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions openquake/calculators/extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion openquake/calculators/tests/scenario_damage_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 1c9e4bd

Please sign in to comment.