From d5096eda24462611fdf50770669f54b1bdcb02ca Mon Sep 17 00:00:00 2001 From: Stephen Moseley Date: Mon, 11 Sep 2023 10:59:02 +0100 Subject: [PATCH] Fixes type casting when data are None --- improver/nbhood/nbhood.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/improver/nbhood/nbhood.py b/improver/nbhood/nbhood.py index f08a3e814b..1778f47535 100644 --- a/improver/nbhood/nbhood.py +++ b/improver/nbhood/nbhood.py @@ -316,11 +316,12 @@ def _calculate_neighbourhood( data[data_mask] = 0 if self.sum_only: - area_sum = None + max_extreme_data = None else: area_sum = self._do_nbhood_sum(valid_data_mask) + max_extreme_data = area_sum.astype(loc_data_dtype) # Where data are all ones in nbhood, result will be same as area_sum - data = self._do_nbhood_sum(data, max_extreme=area_sum.astype(loc_data_dtype)) + data = self._do_nbhood_sum(data, max_extreme=max_extreme_data) if not self.sum_only: with np.errstate(divide="ignore", invalid="ignore"):