Skip to content

Commit

Permalink
Only run fast unstack on numpy arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
max-sixty committed Jan 3, 2021
1 parent 9a53fec commit 88eb42e
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions xarray/core/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -3849,6 +3849,18 @@ def unstack(
or sparse
# numpy full_like only added `shape` in 1.17
or LooseVersion(np.__version__) < LooseVersion("1.17")
# Until https://github.com/pydata/xarray/pull/4751 is resolved,
# we check explicitly whether it's a numpy array. Once that is
# resolved, explicitly exclude pint arrays.
# # pint doesn't implement `np.full_like` in a way that's
# # currently compatible.
# # https://github.com/pydata/xarray/pull/4746#issuecomment-753425173
# # or any(
# # isinstance(v.data, pint_array_type) for v in self.variables.values()
# # )
or any(
not isinstance(v.data, np.array) for v in self.variables.values()
)
):
result = result._unstack_full_reindex(dim, fill_value, sparse)
else:
Expand Down

0 comments on commit 88eb42e

Please sign in to comment.