Skip to content

Commit

Permalink
add defaults to add_missing_bounds
Browse files Browse the repository at this point in the history
test add_missing_bounds default

fix default bounds test
  • Loading branch information
Ana Ordonez committed Nov 27, 2023
1 parent c83f46e commit 9b20abd
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"] # noqa: C901
) -> xr.Dataset: # noqa: C901
"""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 9b20abd

Please sign in to comment.