Skip to content

Commit

Permalink
Apply suggested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Arvind Maan committed Sep 15, 2020
1 parent 3dc8a8b commit 736521c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
16 changes: 8 additions & 8 deletions src/interval.jl
Original file line number Diff line number Diff line change
Expand Up @@ -171,20 +171,20 @@ function Base.last(interval::Interval{T,L,R}) where {T,L,R}
return R !== Unbounded ? interval.last : nothing
end

function Base.min(interval::Interval{T,L,R}; precision=nothing) where {T,L,R}
return Base.first(interval)
function Base.minimum(interval::Interval{T,Closed,R}; precision=nothing) where {T,R}
return first(interval)
end

function Base.min(interval::Interval{T,Open,R}; precision) where {T,R}
return interval.first + precision
function Base.minimum(interval::Interval{T,Open,R}; precision=eps(T)) where {T,R}
return first(interval) + precision
end

function Base.max(interval::Interval{T,L,R}; precision=nothing) where {T,L,R}
return Base.last(interval)
function Base.maximum(interval::Interval{T,Closed,R}; precision=nothing) where {T,R}
return last(interval)
end

function Base.max(interval::Interval{T,L,Open}; precision) where {T,L}
return interval.last - precision
function Base.maximum(interval::Interval{T,L,Open}; precision=eps(T)) where {T,L}
return last(interval) - precision
end

function span(interval::Interval)
Expand Down
4 changes: 2 additions & 2 deletions test/interval.jl
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ isinf(::TimeType) = false
# the value we compare to min/max depends on if the bound is open/closed
min_comp = a in interval ? first(interval) : first(interval) + p
max_comp = b in interval ? last(interval) : last(interval) - p
@test min(interval; precision=p) == min_comp
@test max(interval; precision=p) == max_comp
@test minimum(interval; precision=p) == min_comp
@test maximum(interval; precision=p) == max_comp
@test span(interval) == b - a
@test isclosed(interval) == (L === Closed && R === Closed)
@test isopen(interval) == (L === Open && R === Open)
Expand Down

0 comments on commit 736521c

Please sign in to comment.