From aba37ee102e21bc6faded3bf2047b7031a8a394f Mon Sep 17 00:00:00 2001 From: Tom White Date: Wed, 15 Jan 2025 15:33:37 +0000 Subject: [PATCH 1/2] Changes to allow nan functions to work with xarray --- cubed_xarray/tests/test_xarray.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/cubed_xarray/tests/test_xarray.py b/cubed_xarray/tests/test_xarray.py index 4c74afc..b2a6f0e 100644 --- a/cubed_xarray/tests/test_xarray.py +++ b/cubed_xarray/tests/test_xarray.py @@ -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 @@ -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") @@ -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") @@ -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 @@ -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 From 013a5e0866039c95776cf0eb042138b00c647569 Mon Sep 17 00:00:00 2001 From: Tom White Date: Thu, 6 Feb 2025 12:39:50 +0000 Subject: [PATCH 2/2] No longer xfail TestDataArrayAndDataset::test_reindex Fixed by 'Add scalar support to where' https://github.com/cubed-dev/cubed/pull/679 --- cubed_xarray/tests/test_xarray.py | 1 - 1 file changed, 1 deletion(-) diff --git a/cubed_xarray/tests/test_xarray.py b/cubed_xarray/tests/test_xarray.py index b2a6f0e..5bf682e 100644 --- a/cubed_xarray/tests/test_xarray.py +++ b/cubed_xarray/tests/test_xarray.py @@ -396,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))