Skip to content

Commit

Permalink
Fixed a 32/64 bit bug in oq export loss_maps-stats
Browse files Browse the repository at this point in the history
  • Loading branch information
Michele Simionato committed Feb 7, 2022
1 parent 36369d6 commit bf45a68
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
3 changes: 3 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[Michele Simionato]
* Fixed a 32/64 bit bug in `oq export loss_maps-stats`

python3-oq-engine (3.11.4-1~xenial01) xenial; urgency=low

[Michele Simionato]
Expand Down
9 changes: 6 additions & 3 deletions openquake/risklib/scientific.py
Original file line number Diff line number Diff line change
Expand Up @@ -1036,15 +1036,18 @@ def conditional_loss_ratio(loss_ratios, poes, probability):
interpolate the loss curve
"""
assert len(loss_ratios) >= 3, loss_ratios
probability = numpy.float32(probability)
if not isinstance(loss_ratios, numpy.ndarray):
loss_ratios = numpy.float32(loss_ratios)
if not isinstance(poes, numpy.ndarray):
poes = numpy.float32(poes)
rpoes = poes[::-1]
if probability > poes[0]: # max poes
return 0.0
elif probability < poes[-1]: # min PoE
return loss_ratios[-1]
if probability in poes:
return max([loss
for i, loss in enumerate(loss_ratios)
if probability == poes[i]])
return loss_ratios[probability == poes].max()
else:
interval_index = bisect.bisect_right(rpoes, probability)

Expand Down

0 comments on commit bf45a68

Please sign in to comment.