Skip to content

Commit

Permalink
Avoid breaking compatibility with Julia 1.3.
Browse files Browse the repository at this point in the history
  • Loading branch information
ztangent committed Dec 17, 2023
1 parent 457700a commit b986579
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/abstractions/interval.jl
Original file line number Diff line number Diff line change
Expand Up @@ -103,22 +103,20 @@ function Base.union(a::IntervalAbs, b::IntervalAbs)
end

function Base.intersect(a::IntervalAbs{T}, b::IntervalAbs{U}) where {T, U}
if isdisjoint(a, b)
if a.lo > b.hi || a.hi < b.lo
return empty_interval(promote_type{T, U})
else
return IntervalAbs(max(a.lo, b.lo), min(a.hi, b.hi))
end
end

Base.isdisjoint(a::IntervalAbs, b::IntervalAbs) =
a.lo > b.hi || a.hi < b.lo
Base.issubset(a::IntervalAbs, b::IntervalAbs) =
a.lo >= b.lo && a.hi <= b.hi
Base.in(a::Real, b::IntervalAbs) =
a >= b.lo && a <= b.hi

equiv(a::IntervalAbs, b::IntervalAbs) = !isdisjoint(a.interval, b.interval)
nequiv(a::IntervalAbs, b::IntervalAbs) = isdisjoint(a.interval, b.interval)
equiv(a::IntervalAbs, b::IntervalAbs) = !(a.lo > b.hi || a.hi < b.lo)
nequiv(a::IntervalAbs, b::IntervalAbs) = a.lo > b.hi || a.hi < b.lo
Base.:<(a::IntervalAbs, b::IntervalAbs) = a.lo < b.hi
Base.:<=(a::IntervalAbs, b::IntervalAbs) = a.lo <= b.hi

Expand Down

0 comments on commit b986579

Please sign in to comment.