Skip to content

Commit

Permalink
address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
haberdashPI committed Oct 21, 2022
1 parent 0ec353d commit 375dd59
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions src/interval_sets.jl
Original file line number Diff line number Diff line change
Expand Up @@ -471,11 +471,12 @@ end
"""
find_intersections(x, y)
Returns a `Vector{Vector{Int}}` where the value at index `i` gives the indices to all
intervals in `y` that intersect with `x[i]`. Calls collect on the arguments if they
aren't already arrays.
Find the intervals in `y` that intersect with intervals in `x`. Returns a vector, `z`, where
each element `z[i]` is a vector of all indices in `y` that intersect with `x[i]`. The values
`x` and `y` should be iterables of intervals.
"""
find_intersections(x, y) = find_intersections_(collect(x), collect(y))
find_intersections(x::AbstractVector, y::Abstractvector) = find_intersections_(x, y)
function find_intersections_(x::AbstractVector, y::AbstractVector)
(isempty(x) || isempty(y)) && return Vector{Int}[]
tracking = endpoint_tracking(x, y)
Expand Down
4 changes: 2 additions & 2 deletions test/sets.jl
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ end
@test isempty(find_intersections([], []))
@test_throws MethodError find_intersections([1], [2])
@test isempty(find_intersections(Interval[], Interval[]))
@test isempty(find_intersections([1..3], Interval[]))
@test isempty(find_intersections(Interval[], [1..3]))
@test isempty(find_intersections([1..3], []))
@test isempty(find_intersections([], [1..3]))

function testsets(a, b)
@test area(a b) area(myunion(a)) + area(myunion(b))
Expand Down

0 comments on commit 375dd59

Please sign in to comment.