From 83a3b89bd5fd7109d1ee91e20cfa61911b42f853 Mon Sep 17 00:00:00 2001 From: Maximilian Roos Date: Thu, 31 Dec 2020 15:47:09 -0800 Subject: [PATCH] Hack to get sparse tests passing --- xarray/core/dataset.py | 7 ++++++- xarray/core/variable.py | 2 -- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/xarray/core/dataset.py b/xarray/core/dataset.py index 30cba39d249..0df81999728 100644 --- a/xarray/core/dataset.py +++ b/xarray/core/dataset.py @@ -3832,7 +3832,12 @@ def unstack( result = self.copy(deep=False) for dim in dims: - if sparse: + # FIXME: remove + import sparse as sparse_ + + if sparse or any( + isinstance(v.data, sparse_.COO) for v in self.variables.values() + ): result = result._unstack_once(dim, fill_value, sparse) else: result = result._unstack_once_fast(dim, fill_value, sparse) diff --git a/xarray/core/variable.py b/xarray/core/variable.py index b75def6d509..ec43c3b0ab5 100644 --- a/xarray/core/variable.py +++ b/xarray/core/variable.py @@ -1597,8 +1597,6 @@ def _unstack_once_fast( new_shape = list(reordered.shape[: len(other_dims)]) + new_dim_sizes new_dims = reordered.dims[: len(other_dims)] + new_dim_names - # missing_values = np.prod(new_shape) > np.prod(self.shape) - if fill_value is dtypes.NA: fill_value = dtypes.get_fill_value(self.dtype)