Repository navigation
Check for tricky cases when fusing fancy indices - #2313
Merged
Merged
Conversation
Previously we'd fuse normal and fancy indexing like: ```python a[:, :, [0, 1], :][0, :, :, :] -> a[0, :, [0, 1], :] ``` This is incorrect, and was leading to bugs: ```python >>> a = np.ones((11, 13, 20, 12)) >>> a[:, :, [0, 1], :][0, :, :, :].shape (13, 2, 12) >>> a[0, :, [0, 1], :].shape (2, 13, 12) ``` Let `ind1` and `ind2` represent two index operations as in `x[ind1][ind2]`. We now only fuse indices involving fancy indexing if: - Only one of the two uses fancy indexing - Dimensions where fancy indexing isn't used are non-integers This means that the following will be fused: ``` a[:10, [1, 2, 3]][:5, 0] ``` but this won't: ``` a[:10, [1, 2, 3][0, 0] ``` This does exclude some valid cases, but is easier to write than following all the checks required when mixing fancy and non-fancy indexing.
Member
Author
|
Looks like this also fixes #1770. In [1]: import dask.array as da
In [2]: d1 = da.zeros((1, 9, 3), chunks=(1, 5, 3))
In [3]: d2 = d1[0, :, [0, 2]]
In [4]: d2.compute()
Out[4]:
array([[ 0., 0.],
[ 0., 0.],
[ 0., 0.],
[ 0., 0.],
[ 0., 0.],
[ 0., 0.],
[ 0., 0.],
[ 0., 0.],
[ 0., 0.]]) |
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Previously we'd fuse normal and fancy indexing like:
This is incorrect, and was leading to bugs:
Let
ind1andind2represent two index operations as inx[ind1][ind2]. We now only fuse indices involving fancy indexing if:This means that the following will be fused:
but this won't:
This does exclude some valid cases, but is easier to write than
following all the checks required when mixing fancy and non-fancy
indexing.