From 375dd594019a22e82249e148c320f099caf70ffd Mon Sep 17 00:00:00 2001 From: David F Little Date: Fri, 21 Oct 2022 16:30:42 -0400 Subject: [PATCH] address review comments --- src/interval_sets.jl | 7 ++++--- test/sets.jl | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/interval_sets.jl b/src/interval_sets.jl index 13cf4b58..a470ae7e 100644 --- a/src/interval_sets.jl +++ b/src/interval_sets.jl @@ -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) diff --git a/test/sets.jl b/test/sets.jl index 66fe81d4..c19eab4f 100644 --- a/test/sets.jl +++ b/test/sets.jl @@ -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))