From 5697cf7b6c861029888fb4bbda018f210dcf3ef8 Mon Sep 17 00:00:00 2001 From: Tom Vo Date: Wed, 4 Aug 2021 10:20:09 -0700 Subject: [PATCH] Update tests to pass --- tests/test_bounds.py | 5 ++++- tests/test_variable.py | 3 +++ xcdat/bounds.py | 6 +++--- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/tests/test_bounds.py b/tests/test_bounds.py index 7ee7ed2e..4695349d 100644 --- a/tests/test_bounds.py +++ b/tests/test_bounds.py @@ -179,6 +179,9 @@ class TestDataArrayBoundsAccessor: @pytest.fixture(autouse=True) def setUp(self): self.ds = generate_dataset(has_bounds=True) + self.ds.lat.attrs["bounds"] = "lat_bnds" + self.ds.lon.attrs["bounds"] = "lon_bnds" + self.ds.time.attrs["bounds"] = "time_bnds" def test_decorator_call(self): expected = self.ds.ts @@ -195,7 +198,7 @@ def test__init__(self): assert result.time is None def test__copy_from_parent_copies_bounds(self): - result: DataArrayBoundsAccessor = DataArrayBoundsAccessor(self.ds["ts"]) + result = DataArrayBoundsAccessor(self.ds["ts"]) result._copy_from_dataset(self.ds) assert self.ds.lat_bnds.identical(result.lat) diff --git a/tests/test_variable.py b/tests/test_variable.py index d3bbd120..a801b0b1 100644 --- a/tests/test_variable.py +++ b/tests/test_variable.py @@ -19,6 +19,9 @@ def test_raises_error_if_bounds_dont_exist(self): def test_bound_variables_are_identical_with_parent_dataset(self): ds = generate_dataset(has_bounds=True) + ds.lat.attrs["bounds"] = "lat_bnds" + ds.lon.attrs["bounds"] = "lon_bnds" + ds.time.attrs["bounds"] = "time_bnds" ts = open_variable(ds, "ts") diff --git a/xcdat/bounds.py b/xcdat/bounds.py index 96dfab32..1d64c9b8 100644 --- a/xcdat/bounds.py +++ b/xcdat/bounds.py @@ -277,7 +277,7 @@ def _copy_from_dataset(self, dataset: xr.Dataset): if boundless_coords: raise ValueError( "The dataset is missing bounds for the following coords: " - f"{', '.join(boundless_coords)}. Make sure to open the dataset using " - "`xcdat.dataset.open_dataset` to auto-generate bounds for the dataset " - "before passing it to this function." + f"{', '.join(boundless_coords)}. Pass the dataset to" + "`xcdat.dataset.open_dataset` to auto-generate bounds before passing it " + "to this function." )