diff --git a/CHANGES.rst b/CHANGES.rst index 9e1ffb508..220845c89 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -20,6 +20,7 @@ Bug fixes * Fix the registry entries of "generic" indicators. (:issue:`1423`, :pull:`1424`). * Fix `jetstream_metric_woollings` so it uses the `vertical` coordinate identified by `cf-xarray`, instead of `pressure`. (:issue:`1421`, :pull:`1422`). Add logic to handle coordinates in decreasing order, or for longitudes defined from 0-360 instead of -180 to 180. (:issue:`1429`, :pull:`1430`). * Fix virtual indicator attribute assignment causing individual indicator's realm to be ignored. (:issue:`1425`, :pull:`1426`). +* Fixes the `raise_flags` argument of ``xclim.core.dataflags.data_flags`` so that an Exception is only raised when some checkups fail (:issue:`1456`, :pull:`1457`). Internal changes ^^^^^^^^^^^^^^^^ diff --git a/tests/test_flags.py b/tests/test_flags.py index 6240f2ef1..9bd8b925e 100644 --- a/tests/test_flags.py +++ b/tests/test_flags.py @@ -125,6 +125,9 @@ def test_raises(self, tasmax_series, tasmin_series): arr = series(vals, start="1971-01-01") bad_ds = xr.merge([bad_ds, arr]) + # At this stage, it should not raise an exception + df.data_flags(bad_ds.tasmax, bad_ds, raise_flags=True) + # Swap entire variable arrays bad_ds["tasmin"].values, bad_ds["tasmax"].values = ( bad_ds.tasmax.values, diff --git a/xclim/core/dataflags.py b/xclim/core/dataflags.py index 494e124dc..9b1773c43 100644 --- a/xclim/core/dataflags.py +++ b/xclim/core/dataflags.py @@ -559,7 +559,7 @@ def data_flags( The value can be None if there are no parameters to pass (i.e. default will be used). The default, None, means that the data flags list will be taken from :py:obj:`xclim.core.utils.VARIABLES`. dims : {"all", None} or str or a sequence of strings - Dimenions upon which aggregation should be performed. Default: "all". + Dimensions upon which the aggregation should be performed. Default: "all". freq : str, optional Resampling frequency to have data_flags aggregated over periods. Defaults to None, which means the "time" axis is treated as any other dimension (see `dims`). @@ -692,7 +692,7 @@ def _missing_vars(function, dataset: xarray.Dataset, var_provided: str): dsflags = xarray.Dataset(data_vars=flags) if raise_flags: - if np.any(dsflags.data_vars.values()): + if np.any([dsflags[dv] for dv in dsflags.data_vars]): raise DataQualityException(dsflags) return dsflags