Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow nan functions to work with xarray #30

Merged
merged 2 commits into from
Feb 7, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 4 additions & 10 deletions cubed_xarray/tests/test_xarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,7 @@ def test_transpose(self):
v = self.lazy_var
self.assertLazyAndIdentical(u.T, v.T)

@pytest.mark.xfail(
reason="xarray uses np.pad which is not yet wired up to cubed.pad"
)
@pytest.mark.xfail(reason="needs pad mode='constant_values' in cubed")
def test_shift(self):
u = self.eager_var
v = self.lazy_var
Expand Down Expand Up @@ -193,10 +191,8 @@ def test_pickle(self):
def test_reduce(self):
u = self.eager_var
v = self.lazy_var
# TODO: remove skipna=False (https://github.com/cubed-dev/cubed/issues/153)
self.assertLazyAndAllClose(u.mean(skipna=False), v.mean(skipna=False))
self.assertLazyAndAllClose(u.mean(), v.mean())
# TODO: other reduce functions need work
# self.assertLazyAndAllClose(u.mean(), v.mean())
# self.assertLazyAndAllClose(u.std(), v.std())
# with raise_if_cubed_computes():
# actual = v.argmax(dim="x")
Expand Down Expand Up @@ -345,7 +341,7 @@ def test_lazy_array(self):
self.assertLazyAndAllClose(u, v)
self.assertLazyAndAllClose(-u, -v)
self.assertLazyAndAllClose(u.T, v.T)
# self.assertLazyAndAllClose(u.mean(), v.mean()) # TODO: isn't lazy
self.assertLazyAndAllClose(u.mean(), v.mean())
self.assertLazyAndAllClose(1 + u, 1 + v)

actual = xr.concat([v[:2], v[2:]], "x")
Expand All @@ -362,7 +358,6 @@ def test_compute(self):

assert ((u + 1).data == v2.data).all()

@pytest.mark.xfail(reason="isn't lazy")
def test_groupby(self):
u = self.eager_array
v = self.lazy_array
Expand All @@ -372,7 +367,7 @@ def test_groupby(self):
actual = v.groupby("x").mean(...)
self.assertLazyAndAllClose(expected, actual)

@pytest.mark.xfail(reason="isn't lazy")
@pytest.mark.xfail(reason="needs pad mode='constant_values' in cubed")
def test_rolling(self):
u = self.eager_array
v = self.lazy_array
Expand Down Expand Up @@ -401,7 +396,6 @@ def test_groupby_first_last(self, func):
actual = method(v.groupby("ab"))
self.assertLazyAndAllClose(expected, actual)

@pytest.mark.xfail(reason="isn't lazy")
def test_reindex(self):
u = self.eager_array.assign_coords(y=range(6))
v = self.lazy_array.assign_coords(y=range(6))
Expand Down