Skip to content

Commit

Permalink
Update tests to pass
Browse files Browse the repository at this point in the history
  • Loading branch information
tomvothecoder committed Aug 4, 2021
1 parent ae59892 commit 5697cf7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
5 changes: 4 additions & 1 deletion tests/test_bounds.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions tests/test_variable.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
6 changes: 3 additions & 3 deletions xcdat/bounds.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."
)

0 comments on commit 5697cf7

Please sign in to comment.