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

Fix to the CI tests I submitted #5

Merged
merged 4 commits into from
Feb 20, 2023
Merged

Conversation

SynapticSage
Copy link
Contributor

@SynapticSage SynapticSage commented Feb 19, 2023

"random" but no "ground truth" tests failed on edge cases.

When the sought element is smaller than all search library numbers, method 2 yields a 0, whereas searchsortedprevious yields a 1 (first element in the library). Likewise, for the next method, if it's largest than all elements, searchsortedfirst will give a number that is one larger than the total set length(a)+1.

Forgot to place bounds on the second method when the test element is either larger than all elements in the search list a or smaller than all elements a.

…is smaller than all search library numbers, method 2 yields a 0, whereas searchsortedprevious yields a 1 (first element in the library). Likewise for the next method, if it's largest than all elements, searchsortedfirst will give a number that is one larger than the total set length(a)+1.
@codecov
Copy link

codecov bot commented Feb 19, 2023

Codecov Report

Merging #5 (d3dcbc7) into main (baa4310) will increase coverage by 9.09%.
The diff coverage is 100.00%.

@@             Coverage Diff             @@
##             main        #5      +/-   ##
===========================================
+ Coverage   90.90%   100.00%   +9.09%     
===========================================
  Files           1         1              
  Lines          22        24       +2     
===========================================
+ Hits           20        24       +4     
+ Misses          2         0       -2     
Impacted Files Coverage Δ
src/SearchSortedNearest.jl 100.00% <100.00%> (+9.09%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@SynapticSage
Copy link
Contributor Author

SynapticSage commented Feb 19, 2023

Also on a related note, there is a possible choice here on edge cases that I hadn't considered.

When the search number is smaller than everything, Matlab's interp1(...,'prev') shoots out a NaN. Same when the search is larger than everything, Matlab's interp1(..., 'next') shoots out a NaN if you're number is bigger than the search set. It's sort of telling the user that "no element satisfies the requested nearest but higher or nearest but lower situation".

I wonder if it would make more sense to output an empty [] in these scenarios. If the user asks for a nearest but higher number, and there is none, or the user asks for a nearest but lower number, and there is none, [] would index their array a[ [] ] and show them an empty set. In a sense saying "there is no element satisfying this request".

@joshday
Copy link
Owner

joshday commented Feb 19, 2023

I wonder if it would make more sense to output an empty [] in these scenarios.

I think the searchsorted functions in base return nothing for cases like these and we should follow suit here.

@SynapticSage
Copy link
Contributor Author

That's reasonable. I updated the outputs to nothing for edge cases.

@joshday joshday merged commit aa16b3a into joshday:main Feb 20, 2023
@joshday
Copy link
Owner

joshday commented Feb 20, 2023

Cool, thanks!

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