Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure aggregation control is optional #551

Merged
merged 4 commits into from
Jan 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion intake_esm/cat.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class ESMCatalogModel(pydantic.BaseModel):
esmcat_version: pydantic.StrictStr
attributes: typing.List[Attribute]
assets: Assets
aggregation_control: AggregationControl
aggregation_control: typing.Optional[AggregationControl] = None
id: typing.Optional[str] = ''
catalog_dict: typing.Optional[typing.List[typing.Dict]] = None
catalog_file: pydantic.StrictStr = None
Expand Down
10 changes: 7 additions & 3 deletions tests/test_cat.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
multi_variable_cat,
sample_df,
sample_esmcat_data,
sample_esmcat_data_without_agg,
zarr_cat_aws_cesm,
zarr_cat_pangeo_cmip6,
)
Expand Down Expand Up @@ -54,12 +55,15 @@ def test_esmcatmodel_load(file):
assert isinstance(cat.has_multiple_variable_assets, bool)


def test_esmcatmodel_from_dict():
cat = ESMCatalogModel.from_dict({'esmcat': sample_esmcat_data, 'df': sample_df})
@pytest.mark.parametrize(
'esmcat_data',
[sample_esmcat_data, sample_esmcat_data_without_agg],
)
def test_esmcatmodel_from_dict(esmcat_data):
cat = ESMCatalogModel.from_dict({'esmcat': esmcat_data, 'df': sample_df})
assert isinstance(cat, ESMCatalogModel)
assert isinstance(cat.df, pd.DataFrame)
assert isinstance(cat.columns_with_iterables, set)
assert isinstance(cat.has_multiple_variable_assets, bool)


@pytest.mark.parametrize(
Expand Down