Skip to content

Conversation

@timholy
Copy link
Member

@timholy timholy commented Jan 9, 2018

This deprecates a couple of more methods as part of #23812. It's a small standalone PR to help minimize conflicts between multiple big PRs.

@deprecate findfirst(A, v) findfirst(equalto(v), A)
@deprecate findprev(A, v, i) findprev(equalto(v), A, i)
@deprecate findlast(A, v) findlast(equalto(v), A)
@deprecate findnext(A::BitArray, v, i) findnext(equalto(v), A, i)
Copy link
Member

Choose a reason for hiding this comment

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

Are these two deprecations really needed, given that we have more general versions above?

Copy link
Member Author

Choose a reason for hiding this comment

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

Probably not, though I added them to ensure (mostly) the same specificity we have now. Sort of like your argument above about not removing ::Integer from start.

findfirstnot(B::BitArray) = findnextnot(B,1)

# returns the index of the first matching element
function findnext(B::BitArray, v, start::Integer)
Copy link
Member

Choose a reason for hiding this comment

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

I suspect we should keep these for efficiency, but change the signature to findnext(pred::EqualTo, B::BitArray, start). Then inside the function you need to do v = pred.x.

Copy link
Member Author

Choose a reason for hiding this comment

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

Isn't that mostly covered by this method? The extra code is O(1).

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, maybe. So you think there was no reason for the existence of these methods in the first place?

@deprecate findprev(A, v, i::Integer) findprev(equalto(v), A, i)
@deprecate findlast(A, v) findlast(equalto(v), A)
@deprecate find(x::Number) find(!iszero, x)
@deprecate findnext(A, v, i) findnext(equalto(v), A, i)
Copy link
Member

Choose a reason for hiding this comment

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

You should probably keep ::Integer for deprecations, else they are called incorrectly and make tests fail.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, that was what I was worried about. I'm abandoning the idea of providing a sentinel argument, so keeping this ::Integer isn't so bad anymore.

Copy link
Member

Choose a reason for hiding this comment

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

Note that these are just deprecations, we don't need to support new features for them anyway.

Copy link
Member Author

Choose a reason for hiding this comment

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

I was worried about deprecations causing ambiguities.

@timholy
Copy link
Member Author

timholy commented Jan 9, 2018

I'm going to close this in favor of #25472, but I'll leave the branch around for a bit in case you want it for the ::Integer changes. You'll note I adopted several of your suggestions, @nalimilan.

@timholy timholy closed this Jan 9, 2018
@DilumAluthge DilumAluthge deleted the teh/find_cleanup branch March 25, 2021 22:07
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