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

Handle empty-interval edge case in find_intersections #201

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

haberdashPI
Copy link
Contributor

@haberdashPI haberdashPI commented Oct 6, 2022

Closes #200

Title says it all. This fix also will address some edge cases where find_intersections would throw a StackOverflowError when passed an incorrect type.

Small aside: When I ran tests locally there was a failure on 1.8 (had to run on 1.7). Looks to be related to a now closed issue in 1.8.

@haberdashPI haberdashPI requested a review from omus as a code owner October 6, 2022 15:55
@codecov
Copy link

codecov bot commented Oct 6, 2022

Codecov Report

Merging #201 (8eec69f) into master (2999a5d) will increase coverage by 0.03%.
The diff coverage is 75.00%.

@@            Coverage Diff             @@
##           master     #201      +/-   ##
==========================================
+ Coverage   84.31%   84.35%   +0.03%     
==========================================
  Files          12       12              
  Lines         848      850       +2     
==========================================
+ Hits          715      717       +2     
  Misses        133      133              
Impacted Files Coverage Δ
src/interval_sets.jl 92.21% <75.00%> (+0.06%) ⬆️

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

Copy link
Contributor

@ericphanson ericphanson left a comment

Choose a reason for hiding this comment

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

closes #200?

I suggested arranging the dispatches slightly differently there, which I think has some advantages. With this version:

  • Empty checks are repeated in two methods
  • errors depend on contents, not type: if the array has the wrong type and is empty, no error. Non-empty, and error

src/interval_sets.jl Outdated Show resolved Hide resolved
src/interval_sets.jl Outdated Show resolved Hide resolved
test/sets.jl Outdated Show resolved Hide resolved
src/interval_sets.jl Show resolved Hide resolved
@@ -583,7 +583,7 @@ using Intervals: Bounded, Ending, Beginning, canonicalize, isunbounded
r = r[1:5]

# https://github.com/JuliaLang/julia/issues/33882
@test r isa StepRangeLen
@test r isa (VERSION < v"1.8" ? StepRangeLen : StepRange)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Best to make these fixes as separate PRs so they can be merged faster

Copy link
Collaborator

Choose a reason for hiding this comment

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

After looking into it I think this fix is incorrect. I've made a new fix in #204

Suggested change
@test r isa (VERSION < v"1.8" ? StepRangeLen : StepRange)
@test r isa StepRangeLen

@omus omus mentioned this pull request Oct 18, 2022
@haberdashPI haberdashPI requested a review from omus October 25, 2022 14:46
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.

stackoverflow from recursive call in find_intersections
3 participants