Skip to content

Commit

Permalink
Really fixed the nontrivial taxonomy mapping case
Browse files Browse the repository at this point in the history
  • Loading branch information
micheles committed Nov 9, 2021
1 parent 9417fcb commit 73255be
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions openquake/risklib/riskmodels.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import re
import ast
import copy
import logging
import operator
import functools
import collections
Expand Down Expand Up @@ -708,10 +707,11 @@ def get_output(self, taxo, assets, haz, sec_losses=(), rndgen=None,
# average on the risk models (unsupported for classical)
dic[lt] = outs[0]
if hasattr(dic[lt], 'loss'): # event_based_risk
if weights[0] != 1:
dic[lt].loss *= weights[0]
for alt, w in zip(outs[1:], weights[1:]):
dic[lt].loss = dic[lt].loss.add(alt.loss * w, fill_value=0)
if len(weights) > 1:
# computing the average dataframe
df = pandas.concat(
[out * w for out, w in zip(outs, weights)])
dic[lt] = df.groupby(['eid', 'aid']).sum()
elif len(weights) > 1: # scenario_damage
dic[lt] = numpy.average(outs, weights=weights, axis=0)
# compute secondary losses, if any
Expand Down

0 comments on commit 73255be

Please sign in to comment.