Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lib/DiscreteMeasures/ext/IntervalArithmeticExt.jl
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
module IntervalArithmeticExt

using DiscreteMeasures, IntervalArithmetic
using DiscreteMeasures: DiscreteMeasures, clamp_domain
using IntervalArithmetic: IntervalArithmetic, Interval, interval, intersect_interval

println("Load Ext")
function DiscreteMeasures.clamp_domain(x::Interval, lb, ub)
bounds = interval(lb, ub)
return intersect(x, bounds)
return intersect_interval(x, bounds)
end

function DiscreteMeasures.clamp_weight(w::Interval{T}, maxw::T = one(T)) where {T}
Expand Down
12 changes: 7 additions & 5 deletions lib/DiscreteMeasures/test/Core/discrete_measures_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,13 @@ end
end

@testset "Interval Ext" begin
@test clamp_domain(interval(-2, -1), 0, 2) == emptyinterval()
@test clamp_domain(interval(-2, 1), 0, 2) == interval(0, 1)
@test clamp_domain(interval(0.1, 0.5), 0, 2) == interval(0.1, 0.5)
@test clamp_domain(interval(0.5, 5), 0, 2) == interval(0.5, 2)
@test clamp_domain(interval(3, 4), 0, 2) == emptyinterval()
# IntervalArithmetic 1.x: use isequal_interval — `==` on non-thin
# decorated intervals throws InconclusiveBooleanOperation.
@test isequal_interval(clamp_domain(interval(-2, -1), 0, 2), emptyinterval())
@test isequal_interval(clamp_domain(interval(-2, 1), 0, 2), interval(0, 1))
@test isequal_interval(clamp_domain(interval(0.1, 0.5), 0, 2), interval(0.1, 0.5))
@test isequal_interval(clamp_domain(interval(0.5, 5), 0, 2), interval(0.5, 2))
@test isequal_interval(clamp_domain(interval(3, 4), 0, 2), emptyinterval())
end

end
Loading