From a050b1a730bd51d0677466d0eca8ad10825d2900 Mon Sep 17 00:00:00 2001 From: Ian Langmore Date: Tue, 7 May 2024 09:16:11 -0700 Subject: [PATCH] Require `--quantiles` set if `'quantile' in --stats`. This prevents a mysterious `ZeroDivisionError`. PiperOrigin-RevId: 631445591 --- scripts/compute_climatology.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/compute_climatology.py b/scripts/compute_climatology.py index a32f296..c0a3c4d 100644 --- a/scripts/compute_climatology.py +++ b/scripts/compute_climatology.py @@ -330,6 +330,10 @@ def _compute_seeps(kv): if stat not in ['seeps', 'mean']: for var in raw_vars: if stat == 'quantile': + if not quantiles: + raise ValueError( + 'Cannot compute stat `quantile` without specifying --quantiles.' + ) quantile_dim = xr.DataArray( quantiles, name='quantile', dims=['quantile'] )