Skip to content
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

Change findfirst and findlast to return cartesian indices with HasShape iterators #25655

Merged
merged 2 commits into from
Jan 23, 2018

Conversation

nalimilan
Copy link
Member

@nalimilan nalimilan commented Jan 20, 2018

This represents better the shape of the iterator, and makes generators over arrays consistent with their input array. Keep returning linear indices with HasShape{1} iterators for consistency with vectors. See #10593. Part of #10593.

The first commit is needed for this change, though it makes sense in isolation. It's extracted from #25356, where it received support from @timholy.

@@ -321,7 +321,7 @@ end
@test Base.IteratorSize(product(1:2)) == Base.HasShape{1}()
@test Base.IteratorSize(product(1:2, 1:2)) == Base.HasShape{2}()
@test Base.IteratorSize(product(take(1:2, 1), take(1:2, 1))) == Base.HasShape{2}()
@test Base.IteratorSize(product(take(1:2, 2))) == Base.HasShape{2}()
@test Base.IteratorSize(product(take(1:2, 2))) == Base.HasShape{1}()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this change be moved to the first commit, or is it ok to just squash them?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, good catch. They could be squashed, but since the first one makes sense on its own, probably better keep them separate. I've moved the change to the first commit.

Needed to determine the shape of indices in a type-stable way.
…pe iterators

This represents better the shape of the iterator, and makes generators over
arrays consistent with their input array. Keep returning linear indices with
HasShape{1} iterators for consistency with vectors.
@martinholters
Copy link
Member

Should this have a NEWS entry because it breaks HasShape()?

@mbauman mbauman added breaking This change will break code needs news A NEWS entry is required for this change labels Jan 26, 2018
@nalimilan
Copy link
Member Author

See #25767.

@nalimilan nalimilan removed the needs news A NEWS entry is required for this change label Jan 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking This change will break code search & find The find* family of functions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants