File tree 2 files changed +14
-1
lines changed 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change 81
81
)
82
82
from .missing import get_clean_interp_index
83
83
from .options import OPTIONS , _get_keep_attrs
84
- from .pycompat import is_duck_dask_array , sparse_array_type
84
+ from .pycompat import is_duck_dask_array , pint_array_type , sparse_array_type
85
85
from .utils import (
86
86
Default ,
87
87
Frozen ,
@@ -3849,6 +3849,12 @@ def unstack(
3849
3849
or sparse
3850
3850
# numpy full_like only added `shape` in 1.17
3851
3851
or LooseVersion (np .__version__ ) < LooseVersion ("1.17" )
3852
+ # pint doesn't implement `np.full_like` in a way that's
3853
+ # currently compatible.
3854
+ # https://github.com/pydata/xarray/pull/4746#issuecomment-753425173
3855
+ or any (
3856
+ isinstance (v .data , pint_array_type ) for v in self .variables .values ()
3857
+ )
3852
3858
):
3853
3859
result = result ._unstack_full_reindex (dim , fill_value , sparse )
3854
3860
else :
Original file line number Diff line number Diff line change @@ -35,3 +35,10 @@ def is_duck_dask_array(x):
35
35
cupy_array_type = (cupy .ndarray ,)
36
36
except ImportError : # pragma: no cover
37
37
cupy_array_type = ()
38
+
39
+ try :
40
+ import pint
41
+
42
+ pint_array_type = (pint .Quantity ,)
43
+ except ImportError : # pragma: no cover
44
+ pint_array_type = ()
You can’t perform that action at this time.
0 commit comments