Skip to content

Commit

Permalink
Update pycompat.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Illviljan committed Jul 9, 2024
1 parent d1ed614 commit bbfbca3
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions xarray/namedarray/pycompat.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,14 +161,15 @@ def to_duck_array(
from xarray.core.indexing import ExplicitlyIndexed
from xarray.namedarray.parallelcompat import get_chunked_array_type

if isinstance(data, ExplicitlyIndexed):
return data.get_duck_array() # type: ignore[no-untyped-call, no-any-return]

if is_chunked_array(data):
chunkmanager = get_chunked_array_type(data)
loaded_data, *_ = chunkmanager.compute(data, **kwargs) # type: ignore[var-annotated]
return loaded_data

if isinstance(data, ExplicitlyIndexed):
return data.get_duck_array() # type: ignore[no-untyped-call, no-any-return]
elif is_duck_array(data):
if is_duck_array(data):
return data
else:
return np.asarray(data) # type: ignore[return-value]
return np.asarray(data)

0 comments on commit bbfbca3

Please sign in to comment.