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
3 changes: 2 additions & 1 deletion src/Sets/Interval/IntervalModule.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ using ReachabilityBase.Require: require
isdisjoint, isequivalent, ⊂, ⊆, minkowski_difference,
minkowski_sum
@reexport import ..LazySets: chebyshev_center_radius, isflat, ngens,
radius_hyperrectangle, split
radius_hyperrectangle, rationalize, split
import ..LazySets: plot_recipe
import Base: convert, min, max
@reexport using ..API
Expand All @@ -45,6 +45,7 @@ include("low.jl")
include("norm.jl")
include("radius.jl")
include("rand.jl")
include("rationalize.jl")
include("rectify.jl")
include("reflect.jl")
include("vertices_list.jl")
Expand Down
5 changes: 5 additions & 0 deletions src/Sets/Interval/rationalize.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
function rationalize(::Type{T}, X::Interval{<:AbstractFloat}, tol::Real) where {T<:Integer}
l = rationalize(T, min(X), tol)
h = rationalize(T, max(X), tol)
return Interval(l, h)
end
3 changes: 2 additions & 1 deletion test/Sets/Interval.jl
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,8 @@ for N in [Float64, Float32]
@test_throws AssertionError rand(Interval; N=N, dim=2)

# rationalize
@test_throws MethodError rationalize(X) # TODO is this possible?
Y = rationalize(X)
@test Y isa Interval{Rational{Int64}} && Y == Interval(N(0 // 1), N(2 // 1))

# exponential_map
Y = exponential_map(ones(N, 1, 1), X)
Expand Down
Loading