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

Add defaults to add_missing_bounds #569

Merged
merged 2 commits into from
Nov 27, 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
7 changes: 7 additions & 0 deletions tests/test_bounds.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ def test_adds_x_y_and_z_bounds_to_the_dataset_using_midpoints(self):
result = ds_no_bnds.bounds.add_missing_bounds(axes=["X", "Y", "Z"])
assert result.identical(ds)

def test_adds_default_bounds_to_the_dataset_using_time_frequency(self):
ds = generate_dataset_by_frequency(freq="month")
ds_no_bnds = ds.drop_vars(["time_bnds", "lat_bnds", "lon_bnds"])

result = ds_no_bnds.bounds.add_missing_bounds()
assert result.identical(ds)

def test_adds_t_bounds_to_the_dataset_using_time_frequency(self):
ds = generate_dataset_by_frequency(freq="month")
ds_no_bnds = ds.drop_vars(["time_bnds"])
Expand Down
4 changes: 3 additions & 1 deletion xcdat/bounds.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,9 @@ def keys(self) -> List[str]:
)
)

def add_missing_bounds(self, axes: List[CFAxisKey]) -> xr.Dataset: # noqa: C901
def add_missing_bounds( # noqa: C901
self, axes: List[CFAxisKey] = ["X", "Y", "T"]
) -> xr.Dataset:
"""Adds missing coordinate bounds for supported axes in the Dataset.

This function loops through the Dataset's axes and attempts to adds
Expand Down
Loading