diff --git a/debian/changelog b/debian/changelog index 8a50e372ad6a..e819bca0ab57 100644 --- a/debian/changelog +++ b/debian/changelog @@ -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] diff --git a/openquake/risklib/scientific.py b/openquake/risklib/scientific.py index 373ec5d215d6..864f63009f38 100644 --- a/openquake/risklib/scientific.py +++ b/openquake/risklib/scientific.py @@ -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)