-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add deprecated ind2sub(::NTuple{N,Integer}, ::CartesianIndex{N})
#23708
Conversation
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}())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this just idx.I
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like Tuple(idx)
even if CartesianIndex
objects aren't iterable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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})
Likely unrelated, but has this been seen before? |
Yeah, that's #23796. This should definitely help the transition, thanks! |
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.