-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Only try to call specialized findin method for sorted input when elements are Real. #22010
Conversation
base/array.jl
Outdated
@@ -1791,13 +1791,16 @@ julia> findin(a,b) # 10 is the only common element | |||
4 | |||
``` | |||
""" | |||
function findin(a, b) | |||
function findin(a::Array{<:Real}, b::Union{Array{<:Real,Real}}) |
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 don't understand the union here. Did you mean Union{Array{<:Real}, Real}
? Otherwise this is Array{T, Real} where T<:Real
.
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.
You are right. It is a typo.
elements are Real.
Use total order `isless` for tests Add tests
I've updated this PR with fixes to the algorithm for the issue pointed out in #21934 (comment) and added tests. I had to define |
base/array.jl
Outdated
@@ -1734,6 +1734,9 @@ function _findin(a, b) | |||
ind | |||
end | |||
|
|||
# If two collections are already sorted, findin can be computed with | |||
# a single traversal of the two collections. This is much fast than |
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.
faster than
This should handle the issue mentioned in #21934 (comment). Eventually, we might want to handle this in a smarter way. See #21999.