Skip to content

Commit 103f91e

Browse files
committed
Remove ambiguous set functionalities
1 parent 087a63b commit 103f91e

File tree

3 files changed

+26
-24
lines changed

3 files changed

+26
-24
lines changed

ext/IntervalArithmeticForwardDiffExt.jl

+2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ Base.promote_rule(::Type{Dual{T, V, N}}, ::Type{ExactReal{S}}) where {S<:Real, T
2525

2626
Base.:(==)(x::Interval, y::Dual) = x == value(y)
2727
Base.:(==)(x::Dual, y::Interval) = value(x) == y
28+
Base.:<(x::Interval, y::Dual) = x < value(y)
29+
Base.:<(x::Dual, y::Interval) = value(x) < y
2830

2931
function Base.:(^)(x::Dual{Txy,<:Interval}, y::Dual{Txy,<:Interval}) where {Txy}
3032
vx, vy = value(x), value(y)

src/intervals/real_interface.jl

+22-22
Original file line numberDiff line numberDiff line change
@@ -108,32 +108,32 @@ end
108108
Base.isempty(::Interval) =
109109
throw(ArgumentError("`isempty` is purposely not supported for intervals. See instead `isempty_interval`"))
110110

111-
# Base.isfinite(::Interval) = # also returned when calling `isinf`
112-
# throw(ArgumentError("`isfinite` is purposely not supported for intervals. See instead `isbounded`"))
111+
Base.isfinite(::Interval) = # also returned when calling `isinf`
112+
throw(ArgumentError("`isfinite` is purposely not supported for intervals. See instead `isbounded`"))
113113

114114
Base.isnan(::Interval) =
115115
throw(ArgumentError("`isnan` is purposely not supported for intervals. See instead `isnai`"))
116116

117-
# Base.intersect(::Interval) =
118-
# throw(ArgumentError("`intersect` is purposely not supported for intervals. See instead `intersect_interval`"))
119-
120-
# Base.union!(::BitSet, ::Interval) = # needed to resolve ambiguity
121-
# throw(ArgumentError("`union!` is purposely not supported for intervals. See instead `hull`"))
122-
# Base.union!(::AbstractSet, ::Interval) = # also returned when calling `intersect`, `symdiff` with intervals
123-
# throw(ArgumentError("`union!` is purposely not supported for intervals. See instead `hull`"))
124-
# Base.union!(::AbstractVector{S}, ::Interval) where {S} =
125-
# throw(ArgumentError("`union!` is purposely not supported for intervals. See instead `hull`"))
126-
# Base.union!(::AbstractVector{S}, ::Interval, ::Any, ::Any...) where {S} =
127-
# throw(ArgumentError("`union!` is purposely not supported for intervals. See instead `hull`"))
128-
# Base.union!(::AbstractVector{S}, ::Interval, ::Interval, ::Any...) where {S} =
129-
# throw(ArgumentError("`union!` is purposely not supported for intervals. See instead `hull`"))
130-
# Base.union!(::AbstractVector{S}, ::Any, ::Interval, ::Any...) where {S} =
131-
# throw(ArgumentError("`union!` is purposely not supported for intervals. See instead `hull`"))
132-
133-
# Base.setdiff(::Interval) =
134-
# throw(ArgumentError("`setdiff` is purposely not supported for intervals. See instead `interiordiff`"))
135-
# Base.setdiff!(::AbstractSet, ::Interval) =
136-
# throw(ArgumentError("`setdiff!` is purposely not supported for intervals. See instead `interiordiff`"))
117+
Base.intersect(::Interval) =
118+
throw(ArgumentError("`intersect` is purposely not supported for intervals. See instead `intersect_interval`"))
119+
120+
Base.union!(::BitSet, ::Interval) = # needed to resolve ambiguity
121+
throw(ArgumentError("`union!` is purposely not supported for intervals. See instead `hull`"))
122+
Base.union!(::AbstractSet, ::Interval) = # also returned when calling `intersect`, `symdiff` with intervals
123+
throw(ArgumentError("`union!` is purposely not supported for intervals. See instead `hull`"))
124+
Base.union!(::AbstractVector{S}, ::Interval) where {S} =
125+
throw(ArgumentError("`union!` is purposely not supported for intervals. See instead `hull`"))
126+
Base.union!(::AbstractVector{S}, ::Interval, ::Any, ::Any...) where {S} =
127+
throw(ArgumentError("`union!` is purposely not supported for intervals. See instead `hull`"))
128+
Base.union!(::AbstractVector{S}, ::Interval, ::Interval, ::Any...) where {S} =
129+
throw(ArgumentError("`union!` is purposely not supported for intervals. See instead `hull`"))
130+
Base.union!(::AbstractVector{S}, ::Any, ::Interval, ::Any...) where {S} =
131+
throw(ArgumentError("`union!` is purposely not supported for intervals. See instead `hull`"))
132+
133+
Base.setdiff(::Interval) =
134+
throw(ArgumentError("`setdiff` is purposely not supported for intervals. See instead `interiordiff`"))
135+
Base.setdiff!(::AbstractSet, ::Interval) =
136+
throw(ArgumentError("`setdiff!` is purposely not supported for intervals. See instead `interiordiff`"))
137137

138138
# pointwise equality
139139

test/interval_tests/consistency.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -369,10 +369,10 @@
369369
@test x < y
370370
@test isdisjoint(x, y)
371371
@test !issubset(x, y)
372-
@test !issetequal(x, y)
372+
@test_throws ArgumentError !issetequal(x, y)
373373
@test x y
374374
@test_throws ArgumentError isempty(x)
375-
@test_throws MethodError isfinite(x)
375+
@test_throws ArgumentError isfinite(x)
376376
@test_throws ArgumentError isnan(x)
377377
@test isinteger(x)
378378
@test !isinteger(interval(1.2, 1.9))

0 commit comments

Comments
 (0)