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)