From 9b20abd4ec8bf719f0e06df2e36fec703826c81e Mon Sep 17 00:00:00 2001 From: Ana Ordonez Date: Mon, 27 Nov 2023 13:42:00 -0800 Subject: [PATCH 1/2] add defaults to add_missing_bounds test add_missing_bounds default fix default bounds test --- tests/test_bounds.py | 7 +++++++ xcdat/bounds.py | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) 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..ca048f5a 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"] # 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 From 400cebfcf8f13a2fb328501fcd1084d72230420d Mon Sep 17 00:00:00 2001 From: Ana Ordonez <18147700+acordonez@users.noreply.github.com> Date: Mon, 27 Nov 2023 15:06:22 -0800 Subject: [PATCH 2/2] Move #noqa to first line Co-authored-by: Tom Vo --- xcdat/bounds.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xcdat/bounds.py b/xcdat/bounds.py index ca048f5a..ee59e61c 100644 --- a/xcdat/bounds.py +++ b/xcdat/bounds.py @@ -124,8 +124,8 @@ def keys(self) -> List[str]: ) def add_missing_bounds( # noqa: C901 - self, axes: List[CFAxisKey] = ["X", "Y", "T"] # noqa: C901 - ) -> xr.Dataset: # 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