Support dask array conditional in compress#2555
Merged
jcrist merged 2 commits intodask:masterfrom Jul 25, 2017
Merged
Conversation
Compress now works with dask arrays as conditionals without calling compute on them. If the conditional is concrete we take an optimized path and return an array of known shape. If it's lazy we return an array of unknown shape along the specified axis.
Member
Author
|
cc @jakirkham. |
jakirkham
reviewed
Jul 25, 2017
| for i in range(a.ndim))] | ||
| inds = tuple(range(a.ndim)) | ||
| out = atop(np.compress, inds, condition, (inds[axis],), a, inds, | ||
| axis=axis, dtype=a.dtype) |
Member
There was a problem hiding this comment.
Neat! Was wondering if this was doable with atop, but was not totally figuring out how.
Closed
Implements `da.extract` using `da.compress`.
Member
Author
|
I also added |
Closed
jakirkham
reviewed
Jul 28, 2017
| out = atop(np.compress, inds, condition, (inds[axis],), a, inds, | ||
| axis=axis, dtype=a.dtype) | ||
| out._chunks = tuple((np.NaN,) * len(c) if i == axis else c | ||
| for i, c in enumerate(out.chunks)) |
Member
There was a problem hiding this comment.
As a follow-up, it would be great if there was a formal API for declaring a dimension to be of unknown size.
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.
Compress now works with dask arrays as conditionals without calling compute on them. If the conditional is concrete we take an optimized path and return an array of known shape. If it's lazy we return an array of unknown shape along the specified axis.
Supersedes #2548, fixes #2540.