From a55786a77221857f4210b72faa19ffff1f2972f9 Mon Sep 17 00:00:00 2001 From: Michele Simionato Date: Thu, 21 Sep 2023 10:14:12 +0200 Subject: [PATCH] Better concatenate --- openquake/hazardlib/contexts.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/openquake/hazardlib/contexts.py b/openquake/hazardlib/contexts.py index 5710499ee5d1..d7c84b470aaf 100644 --- a/openquake/hazardlib/contexts.py +++ b/openquake/hazardlib/contexts.py @@ -93,8 +93,10 @@ def split_by_occur(ctx): out.append(ctx[~nan]) nonpoisson = ctx[nan] for shp in set(np.probs_occur.shape[1] for np in nonpoisson): + # ctxs with the same shape of prob_occur are concatenated p_array = [p for p in nonpoisson if p.probs_occur.shape[1] == shp] - out.append(numpy.concatenate(p_array).view(numpy.recarray)) + arr = numpy.concatenate(p_array, p_array[0].dtype) + out.append(arr.view(numpy.recarray)) else: out.append(ctx) return out