Skip to content

Commit 620d346

Browse files
committed
Fix return variable name in gridpoints_core_calc
1 parent bf5d8c9 commit 620d346

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

climada/entity/exposures/litpop/litpop.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,7 +1017,7 @@ def gridpoints_core_calc(
10171017
10181018
Returns
10191019
-------
1020-
result : np.array of same shape as arrays in data_arrays
1020+
np.array of same shape as arrays in data_arrays
10211021
Results from calculation described above.
10221022
"""
10231023
# Convert input data to arrays
@@ -1048,17 +1048,18 @@ def prepare_input(input_data, default_value, name):
10481048
exponents = prepare_input(exponents, 1, "exponents")
10491049

10501050
# Steps 1-3: arrays are multiplied after application of offets and exponents:
1051-
data = data.T # Transpose so that broadcasting over last dimension works
1052-
data = (data + offsets) ** exponents
1053-
result = data.prod(axis=-1).T # Transpose back
1051+
# NOTE: Transpose so that broadcasting over last dimension works. Computing the
1052+
# product over the last axis is also much faster. Then transpose back.
1053+
data = (data.T + offsets) ** exponents
1054+
data = data.prod(axis=-1).T
10541055

10551056
# Steps 4+5: if total value for rescaling is provided, result is normalized and
10561057
# scaled with this total value (total_val_rescale):
10571058
if isinstance(total_val_rescale, (float, int)):
1058-
return result / result.sum() * total_val_rescale
1059+
return data / data.sum() * total_val_rescale
10591060
if total_val_rescale is not None:
10601061
raise TypeError("total_val_rescale must be int or float.")
1061-
return result
1062+
return data
10621063

10631064

10641065
# The following functions are only required if calc_admin1 is True,

0 commit comments

Comments
 (0)