Skip to content

Commit a1e37b9

Browse files
committed
Hack to get sparse tests passing
1 parent 510a6e1 commit a1e37b9

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

xarray/core/dataset.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -3713,7 +3713,6 @@ def _unstack_once_fast(self, dim: Hashable, fill_value, sparse: bool) -> "Datase
37133713
for name, var in self.variables.items():
37143714
if name != dim:
37153715
if dim in var.dims:
3716-
# new_dims = dict(zip(new_dim_names, new_dim_sizes))
37173716
if isinstance(fill_value, Mapping):
37183717
fill_value_ = fill_value[name]
37193718
else:
@@ -3832,7 +3831,12 @@ def unstack(
38323831

38333832
result = self.copy(deep=False)
38343833
for dim in dims:
3835-
if sparse:
3834+
# FIXME: remove
3835+
import sparse as sparse_
3836+
3837+
if sparse or any(
3838+
isinstance(v.data, sparse_.COO) for v in self.variables.values()
3839+
):
38363840
result = result._unstack_once(dim, fill_value, sparse)
38373841
else:
38383842
result = result._unstack_once_fast(dim, fill_value, sparse)

xarray/core/variable.py

-2
Original file line numberDiff line numberDiff line change
@@ -1597,8 +1597,6 @@ def _unstack_once_fast(
15971597
new_shape = list(reordered.shape[: len(other_dims)]) + new_dim_sizes
15981598
new_dims = reordered.dims[: len(other_dims)] + new_dim_names
15991599

1600-
# missing_values = np.prod(new_shape) > np.prod(self.shape)
1601-
16021600
if fill_value is dtypes.NA:
16031601
fill_value = dtypes.get_fill_value(self.dtype)
16041602

0 commit comments

Comments
 (0)