6
6
from datetime import timedelta
7
7
from typing import Any , Callable , Iterable , List , Optional , Tuple , Union
8
8
9
+ import dask .array as da
9
10
import numpy as np
10
11
import pandas as pd
11
12
18
19
is_duck_dask_array ,
19
20
sparse_array_type ,
20
21
)
21
- from .utils import maybe_cast_to_coords_dtype
22
+ from .utils import is_duck_array , maybe_cast_to_coords_dtype
22
23
23
24
24
25
def expanded_indexer (key , ndim ):
@@ -307,7 +308,7 @@ def __init__(self, key):
307
308
for k in key :
308
309
if isinstance (k , slice ):
309
310
k = as_integer_slice (k )
310
- elif isinstance ( k , np . ndarray ):
311
+ elif is_duck_array ( k ):
311
312
if not np .issubdtype (k .dtype , np .integer ):
312
313
raise TypeError (
313
314
f"invalid indexer array, does not have integer dtype: { k !r} "
@@ -320,7 +321,7 @@ def __init__(self, key):
320
321
"invalid indexer key: ndarray arguments "
321
322
f"have different numbers of dimensions: { ndims } "
322
323
)
323
- k = np . asarray ( k , dtype = np .int64 )
324
+ k = k . astype ( np .int64 )
324
325
else :
325
326
raise TypeError (
326
327
f"unexpected indexer type for { type (self ).__name__ } : { k !r} "
@@ -973,7 +974,6 @@ def _arrayize_vectorized_indexer(indexer, shape):
973
974
974
975
def _dask_array_with_chunks_hint (array , chunks ):
975
976
"""Create a dask array using the chunks hint for dimensions of size > 1."""
976
- import dask .array as da
977
977
978
978
if len (chunks ) < array .ndim :
979
979
raise ValueError ("not enough chunks in hint" )
0 commit comments