Skip to content

Commit

Permalink
Add defaults to add_missing_bounds (#569)
Browse files Browse the repository at this point in the history
Co-authored-by: Ana Ordonez <anaordonez@comcast.net>
Co-authored-by: Tom Vo <tomvothecoder@gmail.com>
  • Loading branch information
3 people authored Nov 27, 2023
1 parent c83f46e commit 577d7b6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
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

0 comments on commit 577d7b6

Please sign in to comment.