Skip to content

Commit

Permalink
Merge pull request #223 from JuliaReach/schillic/coverage
Browse files Browse the repository at this point in the history
Fix hiding of more efficient convert method; v0.9.1; increase code coverage
  • Loading branch information
schillic authored Jan 5, 2024
2 parents 7506789 + e6c2c09 commit 24cd4db
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "IntervalMatrices"
uuid = "5c1f47dc-42dd-5697-8aaa-4d102d140ba9"
version = "0.9.0"
version = "0.9.1"

[deps]
IntervalArithmetic = "d1acc4aa-44c8-5952-acd4-ba5d80a2a253"
Expand Down
11 changes: 8 additions & 3 deletions src/IntervalMatrices.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,18 @@ else
vIA = PkgVersion.Version(IntervalArithmetic)
end
if vIA >= v"0.21"
# IntervalArithmetic v0.21 removed convert
# IntervalArithmetic v0.21 removed `convert`
Base.convert(::Type{Interval{T}}, x::Number) where {T} = interval(T(x))
Base.convert(::Type{Interval{T}}, x::Interval{T}) where {T} = x
Base.convert(::Type{Interval{T}}, x::Interval) where {T} = interval(T(inf(x)), T(sup(x)))
function Base.convert(::Type{Interval{T1}}, x::Interval{T2}) where {T1,T2}
return interval(T1(inf(x)), T1(sup(x)))
end
else
# IntervalArithmetic v0.21 requires interval, but prior versions did not offer this method
# COV_EXCL_START
# IntervalArithmetic v0.21 requires `interval`, but prior versions did not
# offer this method for `Complex` inputs
IntervalArithmetic.interval(a::Complex) = complex(interval(real(a)), interval(imag(a)))
# COV_EXCL_STOP
end
if vIA >= v"0.22"
import Base: intersect
Expand Down
4 changes: 2 additions & 2 deletions src/operations/norm.jl
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function _opnorm_inf(A::IntervalMatrix{T}) where {T}
if acc > res
res = acc
end
end
end # COV_EXCL_LINE
return res
end

Expand All @@ -60,7 +60,7 @@ function _opnorm_1(A::IntervalMatrix{T}) where {T}
if acc > res
res = acc
end
end
end # COV_EXCL_LINE
return res
end

Expand Down
12 changes: 12 additions & 0 deletions test/constructors.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
@testset "Interval conversion" begin
x = interval(1.0)

y = convert(Interval{Float64}, x)
# `===` is not applicable here because it just checks value equivalence
# for (immutable) `Interval`s
@test y == x && y isa Interval{Float64}

y = convert(Interval{Float32}, x)
@test y == x && y isa Interval{Float32}
end

@testset "Interval matrix construction" begin
m1 = IntervalMatrix([interval(-1.1, 0.9) interval(-4.1, -3.9); interval(3.8, 4.2) interval(0, 0.9)])
m2 = IntervalMatrix{Float64}(undef, 2, 2)
Expand Down

0 comments on commit 24cd4db

Please sign in to comment.