-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#300 - Correct usage of IntervalArithmetic #316
Conversation
This section illustrates why before we didn't have problems in the tests and now i had to change them, since are using julia> using IntervalArithmetic
julia> Interval(Float32(1.0), Float32(2.0))
[1, 2]
julia> typeof(ans)
IntervalArithmetic.Interval{Float32}
julia> @interval(Float32(1.0), Float32(2.0))
ERROR: MethodError: Cannot `convert` an object of type IntervalArithmetic.Interval{Float64} to an object of type Float32
This may have arisen from a call to the constructor Float32(...),
since type constructors fall back to convert methods.
Stacktrace:
[1] Float32(::IntervalArithmetic.Interval{Float64}) at ./sysimg.jl:77
julia> @interval(1.0, 2.0)
[1, 2]
julia> typeof(ans)
IntervalArithmetic.Interval{Float64}
julia> setprecision(Interval, precision(Float32))
24
julia> @interval(1.0, 2.0)
[1, 2]₂₄
julia> typeof(ans)
IntervalArithmetic.Interval{BigFloat} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well done!
test/unit_overapproximate.jl
Outdated
# for use with other precision, use | ||
# setprecision(IntervalArithmetic.Interval, precision(N)) | ||
# however, this will use BigFloat's of given number of bits, which is a | ||
# different numeric type than d, so this will triggeer a MethodError |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"triggeer"
test/unit_decompose.jl
Outdated
@@ -40,9 +40,12 @@ for N in [Float64, Float32] # TODO Rational{Int} | |||
@test d.array[1] isa Hyperrectangle && test_directions(d.array[1]) | |||
d = decompose(b, set_type=HPolygon, ɛ=to_N(N, 1e-2)) | |||
@test d.array[1] isa HPolygon && test_directions(d.array[1]) | |||
|
|||
if N == Float64 | |||
d = decompose(b, set_type=LazySets.Interval, blocks=ones(Int, 6)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indent?
Actually, the idea of Does that mean that we cannot create 👍 for using |
yes, i think so.
Hmmm... julia> Interval(0, 1)
LazySets.Interval{Float64,IntervalArithmetic.Interval{Float64}}([0, 1])
julia> Interval(0//1, 2//1)
LazySets.Interval{Float64,IntervalArithmetic.Interval{Float64}}([0, 2]) This is not great. At least as you say we should provide constructors. I will ask |
test/unit_decompose.jl
Outdated
@@ -42,8 +41,8 @@ for N in [Float64, Float32] # TODO Rational{Int} | |||
@test d.array[1] isa HPolygon && test_directions(d.array[1]) | |||
|
|||
if N == Float64 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be removed again, right?
Closes #300.