Add deprecated ind2sub(::NTuple{N,Integer}, ::CartesianIndex{N})#23708
Merged
Add deprecated ind2sub(::NTuple{N,Integer}, ::CartesianIndex{N})#23708
ind2sub(::NTuple{N,Integer}, ::CartesianIndex{N})#23708Conversation
ararslan
reviewed
Sep 14, 2017
base/deprecated.jl
Outdated
| # ease transition for return type change of e.g. indmax due to PR #22907 when used in the | ||
| # common pattern `ind2sub(size(a), indmax(a))` | ||
| @deprecate(ind2sub(dims::NTuple{N,Integer}, idx::CartesianIndex{N}) where N, | ||
| ntuple(n -> idx[n], Val{N}())) |
Member
Author
There was a problem hiding this comment.
Yes, but I felt a bit uneasy advertising direct access to an internal field in the deprecation message.
EDIT: With #23719, it could just be Tuple(idx), which would also be quite nice.
Member
There was a problem hiding this comment.
I like Tuple(idx) even if CartesianIndex objects aren't iterable.
Member
Author
There was a problem hiding this comment.
Changed to Tuple(idx).
Makes the return type change of #22907 less breaking by allowing the common pattern `ind2sub(size(a), indmax(a))` to still work.
ab28882 to
5d322a9
Compare
ind2sub(::NTuple{N,Integer}, ::CartesianIndex{N})ind2sub(::NTuple{N,Integer}, ::CartesianIndex{N})
ararslan
approved these changes
Sep 21, 2017
Member
Author
Likely unrelated, but has this been seen before? |
Member
|
Yeah, that's #23796. This should definitely help the transition, thanks! |
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.
Makes the return type change of #22907 less breaking by allowing the
common pattern
ind2sub(size(a), indmax(a))to still work, ref #22907 (comment) in particular.Directly introducing a new method as deprecated is a bit strange, but IMHO this might still make sense.