Skip to content

Commit

Permalink
Hack to get sparse tests passing
Browse files Browse the repository at this point in the history
  • Loading branch information
max-sixty committed Dec 31, 2020
1 parent 510a6e1 commit a1e37b9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 6 additions & 2 deletions xarray/core/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -3713,7 +3713,6 @@ def _unstack_once_fast(self, dim: Hashable, fill_value, sparse: bool) -> "Datase
for name, var in self.variables.items():
if name != dim:
if dim in var.dims:
# new_dims = dict(zip(new_dim_names, new_dim_sizes))
if isinstance(fill_value, Mapping):
fill_value_ = fill_value[name]
else:
Expand Down Expand Up @@ -3832,7 +3831,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)
Expand Down
2 changes: 0 additions & 2 deletions xarray/core/variable.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit a1e37b9

Please sign in to comment.