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

Only try to call specialized findin method for sorted input when elements are Real. #22010

Merged
merged 4 commits into from
May 23, 2017

Conversation

andreasnoack
Copy link
Member

This should handle the issue mentioned in #21934 (comment). Eventually, we might want to handle this in a smarter way. See #21999.

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

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.

Copy link
Member Author

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.

@andreasnoack
Copy link
Member Author

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 eachindex(Number) to make this work but since Numbers work with getindex, I believe this is the right thing to do anyway.

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
Copy link
Contributor

Choose a reason for hiding this comment

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

faster than

@andreasnoack andreasnoack merged commit cfa1999 into master May 23, 2017
@andreasnoack andreasnoack deleted the anj/findin branch May 23, 2017 14:29
@tkelman tkelman mentioned this pull request Jun 10, 2017
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