Skip to content

Commit

Permalink
reduced time required to run operator tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nocollier committed Jan 25, 2024
1 parent e6dfca4 commit 5fd0876
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 31 deletions.
13 changes: 3 additions & 10 deletions intake_esgf/tests/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down Expand Up @@ -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)
25 changes: 4 additions & 21 deletions intake_esgf/tests/test_operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit 5fd0876

Please sign in to comment.