|
1 | 1 | module IntervalSets |
2 | 2 |
|
3 | | -using Base: @pure |
4 | | -import Base: eltype, convert, show, in, length, isempty, isequal, isapprox, issubset, ==, hash, |
| 3 | +import Base: convert, show, in, length, isempty, isequal, isapprox, issubset, ==, hash, |
5 | 4 | union, intersect, minimum, maximum, extrema, range, clamp, mod, float, ⊇, ⊊, ⊋ |
6 | 5 |
|
7 | 6 | using Random |
@@ -62,8 +61,9 @@ isclosedset(d::AbstractInterval) = isleftclosed(d) && isrightclosed(d) |
62 | 61 | "Is the interval open?" |
63 | 62 | isopenset(d::AbstractInterval) = isleftopen(d) && isrightopen(d) |
64 | 63 |
|
65 | | -eltype(::Type{AbstractInterval{T}}) where {T} = T |
66 | | -eltype(::Type{I}) where {I<:AbstractInterval{T}} where T = T |
| 64 | +boundstype(i::AbstractInterval) = boundstype(typeof(i)) |
| 65 | +boundstype(::Type{AbstractInterval{T}}) where {T} = T |
| 66 | +boundstype(::Type{I}) where {I<:AbstractInterval{T}} where T = T |
67 | 67 |
|
68 | 68 | convert(::Type{AbstractInterval}, i::AbstractInterval) = i |
69 | 69 | convert(::Type{AbstractInterval{T}}, i::AbstractInterval{T}) where T = i |
@@ -141,7 +141,7 @@ isequal(A::TypedEndpointsInterval, B::TypedEndpointsInterval) = isempty(A) & ise |
141 | 141 | ==(A::TypedEndpointsInterval{L,R}, B::TypedEndpointsInterval{L,R}) where {L,R} = (leftendpoint(A) == leftendpoint(B) && rightendpoint(A) == rightendpoint(B)) || (isempty(A) && isempty(B)) |
142 | 142 | ==(A::TypedEndpointsInterval, B::TypedEndpointsInterval) = isempty(A) && isempty(B) |
143 | 143 |
|
144 | | -function isapprox(A::AbstractInterval, B::AbstractInterval; atol=0, rtol=Base.rtoldefault(eltype(A), eltype(B), atol), kwargs...) |
| 144 | +function isapprox(A::AbstractInterval, B::AbstractInterval; atol=0, rtol=Base.rtoldefault(boundstype(A), boundstype(B), atol), kwargs...) |
145 | 145 | closedendpoints(A) != closedendpoints(B) && error("Comparing intervals with different closedness is not defined") |
146 | 146 | isempty(A) != isempty(B) && return false |
147 | 147 | isempty(A) && isempty(B) && return true |
|
0 commit comments