Intervals.jl icon indicating copy to clipboard operation
Intervals.jl copied to clipboard

bug in `intersect`

Open ericphanson opened this issue 2 years ago • 3 comments

julia> using Intervals

julia> intersect([Interval{Int, Closed, Open}(1,3), Interval{Int, Closed, Open}(3,5)])
1-element Vector{Interval{Int64, Closed, Open}}:
 Interval{Int64, Closed, Open}(1, 5)

Those two intervals don't have any common elements, so they don't intersect.

ericphanson avatar Jan 06 '23 15:01 ericphanson

That call doesn't actually take the intersection of the two intervals.

To do that:

julia> intersect(Interval{Int, Closed, Open}(1,3), Interval{Int, Closed, Open}(3,5))
Interval{Int64, Open, Open}(0, 0)

Intersect of one argument is an identity operation. For some reason Julia dispatches intersect(s) = union(s), so the misleading union method on arrays of intervals that is currently deprecated takes over. Once that deprecated method is removed, this call will return an array containing the same intervals in the same order.

iamed2 avatar Jan 10 '23 01:01 iamed2

Oh! Ok. That's pretty confusing. Can we do a breaking release & drop the deprecation?

ericphanson avatar Jan 10 '23 20:01 ericphanson

Seems reasonable, although it might be good to address any invalidations that still exist at the same time.

iamed2 avatar Jan 10 '23 21:01 iamed2