From 134ec3744469e432e33ca649f1d122089e3a0b3a Mon Sep 17 00:00:00 2001 From: Manuel Schlund Date: Mon, 7 Feb 2022 17:19:32 +0100 Subject: [PATCH 1/3] Fixed issue with std --- esmvalcore/_recipe_checks.py | 3 ++- tests/integration/test_recipe_checks.py | 20 ++++++-------------- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/esmvalcore/_recipe_checks.py b/esmvalcore/_recipe_checks.py index 2597b10874..a58dfd7e75 100644 --- a/esmvalcore/_recipe_checks.py +++ b/esmvalcore/_recipe_checks.py @@ -13,6 +13,7 @@ from ._data_finder import get_start_end_year from .exceptions import InputFilesNotFound, RecipeError from .preprocessor import TIME_PREPROCESSORS, PreprocessingTask +from .preprocessor._multimodel import STATISTIC_MAPPING logger = logging.getLogger(__name__) @@ -221,7 +222,7 @@ def extract_shape(settings): def _verify_statistics(statistics, step): """Raise error if multi-model statistics cannot be verified.""" - valid_names = ["mean", "median", "std", "min", "max"] + valid_names = ['std'] + list(STATISTIC_MAPPING.keys()) valid_patterns = [r"^(p\d{1,2})(\.\d*)?$"] for statistic in statistics: diff --git a/tests/integration/test_recipe_checks.py b/tests/integration/test_recipe_checks.py index 97b30b8c78..ef441e1969 100644 --- a/tests/integration/test_recipe_checks.py +++ b/tests/integration/test_recipe_checks.py @@ -282,15 +282,11 @@ def test_invalid_multi_model_settings(): def test_invalid_multi_model_statistics(): - with pytest.raises(RecipeError) as rec_err: + msg = (r"Invalid value encountered for `statistic` in preprocessor " + r"multi_model_statistics. Valid values are .* Got 'wrong'.") + with pytest.raises(RecipeError, match=msg): check._verify_statistics( INVALID_MM_SETTINGS['statistics'], 'multi_model_statistics') - assert str(rec_err.value) == ( - "Invalid value encountered for `statistic` in preprocessor " - "multi_model_statistics. Valid values are " - "['mean', 'median', 'std', 'min', 'max'] " - "or patterns matching ['^(p\\\\d{1,2})(\\\\.\\\\d*)?$']. " - "Got 'wrong'.") def test_invalid_multi_model_span(): @@ -323,11 +319,7 @@ def test_invalid_multi_model_keep_input(): def test_invalid_ensemble_statistics(): - with pytest.raises(RecipeError) as rec_err: + msg = (r"Invalid value encountered for `statistic` in preprocessor " + r"ensemble_statistics. Valid values are .* Got 'wrong'.") + with pytest.raises(RecipeError, match=msg): check._verify_statistics(['wrong'], 'ensemble_statistics') - assert str(rec_err.value) == ( - "Invalid value encountered for `statistic` in preprocessor " - "ensemble_statistics. Valid values are " - "['mean', 'median', 'std', 'min', 'max'] " - "or patterns matching ['^(p\\\\d{1,2})(\\\\.\\\\d*)?$']. " - "Got 'wrong'.") From ca42a3e1ce1d7e762bff95f103dc72c7514e36bd Mon Sep 17 00:00:00 2001 From: Manuel Schlund Date: Mon, 7 Feb 2022 17:19:39 +0100 Subject: [PATCH 2/3] Used different intersphinc mapping for scipy --- doc/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/conf.py b/doc/conf.py index fb88705078..96ed84304d 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -424,7 +424,7 @@ 'numpy': ('https://numpy.org/doc/stable/', None), 'pyesgf': ('https://esgf-pyclient.readthedocs.io/en/latest/', None), 'python': ('https://docs.python.org/3/', None), - 'scipy': ('https://docs.scipy.org/doc/scipy/reference/', None), + 'scipy': ('https://scipy.github.io/devdocs/', None), } # -- Custom Document processing ---------------------------------------------- From 3126ddffe9531981fd827246a15520b9d4ac6a53 Mon Sep 17 00:00:00 2001 From: Manuel Schlund Date: Mon, 7 Feb 2022 17:22:18 +0100 Subject: [PATCH 3/3] Fixed doc --- doc/recipe/preprocessor.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/recipe/preprocessor.rst b/doc/recipe/preprocessor.rst index 8fe97ae41a..b3e188c162 100644 --- a/doc/recipe/preprocessor.rst +++ b/doc/recipe/preprocessor.rst @@ -936,7 +936,7 @@ observational data, these biases have a significantly lower statistical impact when using a multi-model ensemble. ESMValTool has the capability of computing a number of multi-model statistical measures: using the preprocessor module ``multi_model_statistics`` will enable the user to ask for either a multi-model -``mean``, ``median``, ``max``, ``min``, ``std``, and / or ``pXX.YY`` with a set +``mean``, ``median``, ``max``, ``min``, ``std_dev``, and / or ``pXX.YY`` with a set of argument parameters passed to ``multi_model_statistics``. Percentiles can be specified like ``p1.5`` or ``p95``. The decimal point will be replaced by a dash in the output file.