From 5fd0876b33d044cd4c261306e59d8ba8bc31167c Mon Sep 17 00:00:00 2001 From: Nathan Collier Date: Thu, 25 Jan 2024 14:47:36 -0500 Subject: [PATCH] reduced time required to run operator tests --- intake_esgf/tests/test_basic.py | 13 +++---------- intake_esgf/tests/test_operators.py | 25 ++++--------------------- 2 files changed, 7 insertions(+), 31 deletions(-) diff --git a/intake_esgf/tests/test_basic.py b/intake_esgf/tests/test_basic.py index 53c4bf3..ebed7e9 100644 --- a/intake_esgf/tests/test_basic.py +++ b/intake_esgf/tests/test_basic.py @@ -28,6 +28,9 @@ def test_esgroot(): ) ds = cat.to_dataset_dict(add_measures=False) assert "gpp" in ds + log = cat.session_log() + assert "download" not in log + assert f"accessed {cat.esgf_data_root}" in cat.session_log() def test_noresults(): @@ -90,16 +93,6 @@ def test_remove_ensemble(): assert cat.df.iloc[0]["member_id"] == "r1i1p1f2" -def test_log(): - cat = ESGFCatalog().search( - experiment_id="historical", - source_id="CanESM5", - variable_id=["gpp"], - variant_label=["r1i1p1f1"], - ) - assert "CanESM5" in cat.session_log() - - def test_download_dbase(): cat = ESGFCatalog() assert len(cat.download_summary().columns) diff --git a/intake_esgf/tests/test_operators.py b/intake_esgf/tests/test_operators.py index 8a51340..1bf86dd 100644 --- a/intake_esgf/tests/test_operators.py +++ b/intake_esgf/tests/test_operators.py @@ -15,34 +15,17 @@ def test_global_mean(): cat = ESGFCatalog().search( experiment_id=["historical"], source_id="CanESM5", - activity_id="CMIP", variant_label="r1i1p1f1", - variable_id=["nbp", "tas", "fgco2"], + variable_id=["gpp", "fgco2"], frequency="mon", ) dsd = cat.to_dataset_dict(ignore_facets=["table_id"]) dsd = trim_time(dsd) dsd = ops.global_mean(dsd) - assert set(["fgco2", "tas", "nbp"]) == set(dsd.keys()) + assert set(["fgco2", "gpp"]) == set(dsd.keys()) def test_ensemble_mean(): - cat = ESGFCatalog().search( - experiment_id="historical", - source_id=["CESM2", "CanESM5"], - variant_label=["r1i1p1f1", "r2i1p1f1", "r3i1p1f1"], - variable_id=["tas", "pr"], - frequency="mon", - ) - dsd = cat.to_dataset_dict(ignore_facets=["institution_id", "table_id"]) - dsd = trim_time(dsd) - dsd = ops.ensemble_mean(dsd) - assert set( - ["CESM2.mean.pr", "CESM2.mean.tas", "CanESM5.mean.pr", "CanESM5.mean.tas"] - ) == set(dsd.keys()) - - -def test_composition(): """Run a test on composition of operators. Operators may be locally defined, but we expect that the only argument taken is a @@ -54,8 +37,8 @@ def test_composition(): cat = ESGFCatalog().search( experiment_id="historical", source_id=["CanESM5"], - variant_label=["r1i1p1f1", "r2i1p1f1", "r3i1p1f1"], - variable_id=["tas"], + variant_label=["r1i1p1f1", "r2i1p1f1"], + variable_id=["gpp"], frequency="mon", ) ensemble_mean = partial(ops.ensemble_mean, include_std=True)