Skip to content

Commit 88eb42e

Browse files
committed
Only run fast unstack on numpy arrays
1 parent 9a53fec commit 88eb42e

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

xarray/core/dataset.py

+12
Original file line numberDiff line numberDiff line change
@@ -3849,6 +3849,18 @@ def unstack(
38493849
or sparse
38503850
# numpy full_like only added `shape` in 1.17
38513851
or LooseVersion(np.__version__) < LooseVersion("1.17")
3852+
# Until https://github.com/pydata/xarray/pull/4751 is resolved,
3853+
# we check explicitly whether it's a numpy array. Once that is
3854+
# resolved, explicitly exclude pint arrays.
3855+
# # pint doesn't implement `np.full_like` in a way that's
3856+
# # currently compatible.
3857+
# # https://github.com/pydata/xarray/pull/4746#issuecomment-753425173
3858+
# # or any(
3859+
# # isinstance(v.data, pint_array_type) for v in self.variables.values()
3860+
# # )
3861+
or any(
3862+
not isinstance(v.data, np.array) for v in self.variables.values()
3863+
)
38523864
):
38533865
result = result._unstack_full_reindex(dim, fill_value, sparse)
38543866
else:

0 commit comments

Comments
 (0)