File tree Expand file tree Collapse file tree 2 files changed +14
-19
lines changed Expand file tree Collapse file tree 2 files changed +14
-19
lines changed Original file line number Diff line number Diff line change @@ -1886,14 +1886,14 @@ def get_duck_array(self) -> np.ndarray | PandasExtensionArray:
1886
1886
return PandasExtensionArray (self .array .array )
1887
1887
return np .asarray (self )
1888
1888
1889
- async def async_get_duck_array (self ) -> np .ndarray | PandasExtensionArray :
1890
- # TODO this must surely be wrong - it's not async yet
1891
- print ("in PandasIndexingAdapter" )
1892
- if pd .api .types .is_extension_array_dtype (self .array ):
1893
- from xarray .core .extension_array import PandasExtensionArray
1894
-
1895
- return PandasExtensionArray (self .array .array )
1896
- return np .asarray (self )
1889
+ # async def async_get_duck_array(self) -> np.ndarray | PandasExtensionArray:
1890
+ # # TODO this must surely be wrong - it's not async yet
1891
+ # print("in PandasIndexingAdapter")
1892
+ # if pd.api.types.is_extension_array_dtype(self.array):
1893
+ # from xarray.core.extension_array import PandasExtensionArray
1894
+
1895
+ # return PandasExtensionArray(self.array.array)
1896
+ # return np.asarray(self)
1897
1897
1898
1898
@property
1899
1899
def shape (self ) -> _Shape :
Original file line number Diff line number Diff line change @@ -153,20 +153,15 @@ async def async_to_duck_array(
153
153
from xarray .core .indexing import (
154
154
ExplicitlyIndexed ,
155
155
ImplicitToExplicitIndexingAdapter ,
156
+ IndexingAdapter ,
156
157
)
157
- from xarray .namedarray .parallelcompat import get_chunked_array_type
158
158
159
159
print (type (data ))
160
-
161
- if is_chunked_array (data ):
162
- chunkmanager = get_chunked_array_type (data )
163
- loaded_data , * _ = chunkmanager .compute (data , ** kwargs ) # type: ignore[var-annotated]
164
- return loaded_data
165
-
166
- if isinstance (data , ExplicitlyIndexed | ImplicitToExplicitIndexingAdapter ):
160
+ if isinstance (data , IndexingAdapter ):
161
+ # These wrap in-memory arrays, and async isn't needed
162
+ return data .get_duck_array ()
163
+ elif isinstance (data , ExplicitlyIndexed | ImplicitToExplicitIndexingAdapter ):
167
164
print ("async inside to_duck_array" )
168
165
return await data .async_get_duck_array () # type: ignore[no-untyped-call, no-any-return]
169
- elif is_duck_array (data ):
170
- return data
171
166
else :
172
- return np . asarray (data ) # type: ignore[return-value]
167
+ return to_duck_array (data , ** kwargs )
You can’t perform that action at this time.
0 commit comments