'Indexing a `numpy.array` with a `dask.array`

I am getting errors when indexing a numpy.array with a dask.array, I'm not sure whether this is a feature or a bug.

In [1]: import numpy as np
In [2]: import dask.array as dka
In [3]: foo = np.arange(10)
In [4]: bar = np.arange(3)

In [5]: foo[bar]
Out[5]: array([0, 1, 2])

In [6]: foo[dka.from_array(bar)]
<ipython-input-16-9c4b06c0d0c4>:1: FutureWarning: Using a non-tuple sequence for multidimensional indexing is deprecated; use `arr[tuple(seq)]` instead of `arr[seq]`. In the future this will be interpreted as an array index, `arr[np.array(seq)]`, which will result either in an error or a different result.
  foo[dka.from_array(bar)]
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-16-9c4b06c0d0c4> in <module>
----> 1 foo[dka.from_array(bar)]

IndexError: too many indices for array: array is 1-dimensional, but 3 were indexed

I am using versions dask==2022.01.0 and numpy==1.22.0.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source