Repository navigation
Allows optional axis argument in Dask Array squeeze method - #3261
Merged
Merged
Conversation
Member
Author
|
May need a changelog entry. If so, will handle after PR ( #3260 ) is merged. |
jakirkham
force-pushed
the
opt_axis_squeeze
branch
3 times, most recently
from
March 9, 2018 05:17
6a8f6ca to
ce87b98
Compare
The `squeeze` method in NumPy takes an optional `axis` as does the function. However we only support `axis` in the Dask Array function and not the method. This brings the Dask Array `squeeze` method up to parity with its NumPy counterpart by adding the optional `axis` argument.
jakirkham
force-pushed
the
opt_axis_squeeze
branch
3 times, most recently
from
March 9, 2018 05:43
614f451 to
e528e03
Compare
To generalize squeeze a bit and simplify it as well, just make use of item selection to squeeze axes.
jakirkham
force-pushed
the
opt_axis_squeeze
branch
from
March 9, 2018 06:51
e528e03 to
70cc82a
Compare
mrocklin
reviewed
Mar 9, 2018
| axis = tuple(i for i, d in enumerate(a.shape) if d == 1) | ||
| b = a.map_blocks(partial(np.squeeze, axis=axis), dtype=a.dtype) | ||
| chunks = tuple(bd for bd in b.chunks if bd != (1,)) | ||
| else: |
Member
Author
There was a problem hiding this comment.
Yes, this handles both int and tuples of ints. It coerces the former into the latter first (maybe part of the confusion). Then applies some checks and normalizes the input data. None of these checks or normalization are required for None as the data is already constructed to meet our expectations.
Member
There was a problem hiding this comment.
I agree that the body of the else is useful. I think we should the normalization code regardless, just to reduce the code nesting.
Member
|
Small comment, otherwise seems good to me |
Member
Author
|
Alright, think this is ready to go in now. :) |
Member
Author
|
Forgot a changelog entry. Adding in PR ( #3321 ). |
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.
Fixes #3259