Skip to content

Add deprecated ind2sub(::NTuple{N,Integer}, ::CartesianIndex{N})#23708

Merged
mbauman merged 1 commit intomasterfrom
mh/ind2sub_for_22907
Sep 22, 2017
Merged

Add deprecated ind2sub(::NTuple{N,Integer}, ::CartesianIndex{N})#23708
mbauman merged 1 commit intomasterfrom
mh/ind2sub_for_22907

Conversation

@martinholters
Copy link
Copy Markdown
Member

@martinholters martinholters commented Sep 14, 2017

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.

# 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}()))
Copy link
Copy Markdown
Member

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?

Copy link
Copy Markdown
Member Author

@martinholters martinholters Sep 15, 2017

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.

Copy link
Copy Markdown
Member

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.

Copy link
Copy Markdown
Member Author

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.
@martinholters martinholters changed the title RFC: Add deprecated ind2sub(::NTuple{N,Integer}, ::CartesianIndex{N}) Add deprecated ind2sub(::NTuple{N,Integer}, ::CartesianIndex{N}) Sep 21, 2017
@martinholters
Copy link
Copy Markdown
Member Author

	From worker 4:	signal (11): Segmentation fault
	From worker 4:	in expression starting at /tmp/julia/share/julia/test/vecelement.jl:60
	From worker 4:	Type at /tmp/julia/share/julia/test/vecelement.jl:49

Likely unrelated, but has this been seen before?

@mbauman
Copy link
Copy Markdown
Member

mbauman commented Sep 22, 2017

Yeah, that's #23796. This should definitely help the transition, thanks!

@mbauman mbauman merged commit 942b843 into master Sep 22, 2017
@mbauman mbauman deleted the mh/ind2sub_for_22907 branch September 22, 2017 15:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants