5
5
from contextlib import suppress
6
6
from datetime import timedelta
7
7
from typing import Any , Callable , Iterable , List , Optional , Tuple , Union
8
+ import dask .array as da
8
9
9
10
import numpy as np
10
11
import pandas as pd
@@ -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 isinstance (k , np .ndarray ) or isinstance ( k , da . Array ) :
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,10 @@ 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
+ if isinstance (k , da .Array ):
325
+ k = da .asarray (k , dtype = np .int64 )
326
+ else :
327
+ k = np .asarray (k , dtype = np .int64 )
324
328
else :
325
329
raise TypeError (
326
330
f"unexpected indexer type for { type (self ).__name__ } : { k !r} "
@@ -973,7 +977,6 @@ def _arrayize_vectorized_indexer(indexer, shape):
973
977
974
978
def _dask_array_with_chunks_hint (array , chunks ):
975
979
"""Create a dask array using the chunks hint for dimensions of size > 1."""
976
- import dask .array as da
977
980
978
981
if len (chunks ) < array .ndim :
979
982
raise ValueError ("not enough chunks in hint" )
0 commit comments