diff --git a/Project.toml b/Project.toml index ca7c4c9..e7b994d 100644 --- a/Project.toml +++ b/Project.toml @@ -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" diff --git a/src/IntervalMatrices.jl b/src/IntervalMatrices.jl index 3c5a369..0e6e23e 100644 --- a/src/IntervalMatrices.jl +++ b/src/IntervalMatrices.jl @@ -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 diff --git a/src/operations/norm.jl b/src/operations/norm.jl index cc16c57..e66dd5b 100644 --- a/src/operations/norm.jl +++ b/src/operations/norm.jl @@ -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 @@ -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 diff --git a/test/constructors.jl b/test/constructors.jl index 9c0ddce..6290761 100644 --- a/test/constructors.jl +++ b/test/constructors.jl @@ -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)