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

Approximate search now returns nothing when no match is found #176

Merged
merged 2 commits into from
Aug 5, 2021

Conversation

jakobnissen
Copy link
Member

Approximate search functions now return nothing when no match is found. These are:

  • approxsearch
  • approxrsearch
  • approxsearchindex
  • approxrsearchindex

Behaviour is otherwise unaltered. Specifically, search for an empty sequence is valid, and returns an empty range, just like before. Weird, but it's consistent with how string search works in Base.

@codecov
Copy link

codecov bot commented Jul 24, 2021

Codecov Report

Merging #176 (3200f9c) into v3 (a8e5b48) will increase coverage by 0.08%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##               v3     #176      +/-   ##
==========================================
+ Coverage   82.16%   82.24%   +0.08%     
==========================================
  Files          31       31              
  Lines        2159     2169      +10     
==========================================
+ Hits         1774     1784      +10     
  Misses        385      385              
Flag Coverage Δ
unittests 82.24% <100.00%> (+0.08%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/search/approx.jl 95.72% <100.00%> (+0.39%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a8e5b48...3200f9c. Read the comment docs.

@jakobnissen
Copy link
Member Author

Okay, this is good to go. Leaving it up for some days or weeks if anyone wants to review it.

@CiaranOMara
Copy link
Member

CiaranOMara commented Jul 28, 2021

Is it intended that the isempty checks return a range?

I haven't thought this through, though; I wonder whether a range result could be useful for chaining/currying searches in that the result provides the start position for the next search, removing the need to track position?

findfirst(seq, vague_query) |> 
    (r) -> findfirst(seq, query, first(r), last(r))  |> 
    (r) -> findfirst(seq, specific_query, first(r), last(r))

@jakobnissen
Copy link
Member Author

@CiaranOMara

Is it intended that the isempty checks return a range?

Yes. It's weird, but this is what Base does with strings (and it's also what BioSequences did until now).
A range results for a failure of a match can be useful in some cases. But it can also be a bit of a trap. If it returns nothing, then the user can implement whatever they want upon a non-match, including continuing to another search.

Merging this for now.

@jakobnissen jakobnissen merged commit b369c76 into BioJulia:v3 Aug 5, 2021
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.

None yet

2 participants