diff --git a/src/cr/cube/crunch_cube.py b/src/cr/cube/crunch_cube.py index dee38d221..94defe494 100644 --- a/src/cr/cube/crunch_cube.py +++ b/src/cr/cube/crunch_cube.py @@ -1159,7 +1159,14 @@ def pvals(self, weighted=True, prune=False, hs_dims=None): crunch cube. ''' stats = self.zscore(weighted=weighted, prune=prune, hs_dims=hs_dims) - return 2 * (1 - norm.cdf(np.abs(stats))) + res = 2 * (1 - norm.cdf(np.abs(stats))) + + if isinstance(stats, np.ma.core.MaskedArray): + # Explicit setting of the mask is necessary, because the norm.cdf + # creates a non-masked version + res = np.ma.masked_array(res, stats.mask) + + return res def scale_means(self): '''Get cube means.'''