Clarify differences in boolean indexing between dask and numpy arrays#6764
Merged
jsignell merged 3 commits intodask:masterfrom Oct 26, 2020
Merged
Conversation
dask does boolean indexing differently compared to numpy, add a hint how it's done in the error. Make if-condition a little easier to read.
jsignell
reviewed
Oct 23, 2020
Member
jsignell
left a comment
There was a problem hiding this comment.
Thanks for opening this! Now that I've seen it, I think the hint should live in the __setitem__ method. That way we don't need to change the logic in broadcast_shapes, we can just add an extra hint to the original error message. Something like this:
try:
y = where(key, value, self)
except ValueError as e:
raise ValueError(
"Boolean index assignment in Dask "
"expects equally shaped arrays. Example: da1[da2] = da3"
"where da1.shape == (4,) and da3.shape == (4,)."
) from ehere:
Line 1550 in 46ef300
Contributor
Author
|
Thanks! I didn't know about chaining errors like that. The error looks like this now: (...)
ValueError: Boolean index assignment in Dask expects equally shaped arrays.
Example: da1[da2] = da3 where da1.shape == (4,), da2.shape == (4,) and da3.shape == (4,). |
jsignell
approved these changes
Oct 26, 2020
Member
jsignell
left a comment
There was a problem hiding this comment.
Thanks for this! It looks great!
kumarprabhu1988
pushed a commit
to kumarprabhu1988/dask
that referenced
this pull request
Oct 29, 2020
…dask#6764) * Hint how to do boolean indexing dask does boolean indexing differently compared to numpy, add a hint how it's done in the error. Make if-condition a little easier to read. * Undo condition changes * Move error tot setitem instead.
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.
Dask arrays does boolean indexing differently compared to numpy arrays.
Add a hint how it's done in the error, the hint is displayed when some shape is nan.
Related issue: #6711