Skip to content

Commit

Permalink
added test, improve docs
Browse files Browse the repository at this point in the history
  • Loading branch information
haberdashPI committed Oct 25, 2022
1 parent 03683c8 commit 8eec69f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/interval_sets.jl
Original file line number Diff line number Diff line change
Expand Up @@ -471,9 +471,9 @@ end
"""
find_intersections(x, y)
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.
For each interval in `x` find all intervals in `y` that it intersects with. 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)
Expand Down
3 changes: 3 additions & 0 deletions test/sets.jl
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,14 @@ end
@test !issubset(11, IntervalSet([1..3, 5..10]))
@test issubset(2, IntervalSet([1.0 .. 3.0, 5.0 .. 10.0]))

# verify the various input types `find_intersections` can handle
@test isempty(find_intersections([], []))
@test_throws MethodError find_intersections([1], [2])
@test isempty(find_intersections(Interval[], Interval[]))
@test isempty(find_intersections([1..3], []))
@test isempty(find_intersections([], [1..3]))
@test !isempty(find_intersections([1..2, 3..4],
AnchoredInterval{-1}(1):1:AnchoredInterval{-1}(5)))

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

0 comments on commit 8eec69f

Please sign in to comment.