diff --git a/tests/test_bounds.py b/tests/test_bounds.py index 33befaad..4e2fd028 100644 --- a/tests/test_bounds.py +++ b/tests/test_bounds.py @@ -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"]) diff --git a/xcdat/bounds.py b/xcdat/bounds.py index 711c94aa..ee59e61c 100644 --- a/xcdat/bounds.py +++ b/xcdat/bounds.py @@ -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