diff --git a/Project.toml b/Project.toml index 6edd6c9..ab40c5a 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "TaylorModels" uuid = "314ce334-5f6e-57ae-acf6-00b6e903104a" repo = "https://github.com/JuliaIntervals/TaylorModels.jl.git" -version = "0.7.0" +version = "0.7.1" [deps] IntervalArithmetic = "d1acc4aa-44c8-5952-acd4-ba5d80a2a253" @@ -15,10 +15,12 @@ TaylorIntegration = "92b13dbe-c966-51a2-8445-caca9f8a7d42" TaylorSeries = "6aa5eb33-94cf-58f4-a9d0-e4b2c4fc25ea" [compat] +Aqua = "0.8" IntervalArithmetic = "^0.20" IntervalRootFinding = "0.5" LinearAlgebra = "<0.0.1, 1" Markdown = "<0.0.1, 1" +Random = "<0.0.1, 1" RecipesBase = "1" Reexport = "1" TaylorIntegration = "0.15" @@ -27,9 +29,10 @@ Test = "<0.0.1, 1" julia = "1" [extras] +Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [targets] -test = ["LinearAlgebra", "Random", "Test"] +test = ["Aqua", "LinearAlgebra", "Random", "Test"] diff --git a/src/TaylorModels.jl b/src/TaylorModels.jl index 65e0553..4fd1035 100644 --- a/src/TaylorModels.jl +++ b/src/TaylorModels.jl @@ -24,8 +24,6 @@ import TaylorSeries: integrate, get_order, evaluate, pretty_print, constant_term, linear_polynomial, nonlinear_polynomial, fixorder, get_numvars -import IntervalArithmetic: showfull - import LinearAlgebra: norm export TaylorModel1, RTaylorModel1, TaylorModelN, TMSol diff --git a/src/evaluate.jl b/src/evaluate.jl index 8de2986..5c429cd 100644 --- a/src/evaluate.jl +++ b/src/evaluate.jl @@ -94,7 +94,7 @@ evaluate(tm::Vector{TaylorModelN{N,T,S}}, a::IntervalBox{N,S}) where {N,T,S} = IntervalBox( [ tm[i](a) for i in eachindex(tm) ] ) -function evaluate(a::Taylor1{TaylorModelN{N,T,S}}, dx::T) where {N, T<:Number, S<:Number} +function evaluate(a::Taylor1{TaylorModelN{N,T,S}}, dx::T) where {N, T<:Real, S<:Real} @inbounds suma = a[end]*one(dx) @inbounds for k in get_order(a)-1:-1:0 suma = suma*dx + a[k] diff --git a/src/promotion.jl b/src/promotion.jl index 1b5be31..32a1364 100644 --- a/src/promotion.jl +++ b/src/promotion.jl @@ -9,8 +9,8 @@ function promote(a::TaylorModelN{N,T,S}, b::R) where {N, T<:Real, S<:Real, R<:Re return (TaylorModelN(apol, a_rem, expansion_point(a), domain(a)), TaylorModelN(bb, zero(a_rem), expansion_point(a), domain(a))) end -promote(b::R, a::TaylorModelN{N,T,S}) where {N, T<:Real, S<:Real, R<:Real} = - reverse(promote(a,b)) +# promote(b::R, a::TaylorModelN{N,T,S}) where {N, T<:Real, S<:Real, R<:Real} = +# reverse(promote(a,b)) # function promote(a::TaylorModelN{N,T,S}, b::TaylorN{R}) where {N, T, S, R} @@ -19,7 +19,7 @@ function promote(a::TaylorModelN{N,T,S}, b::TaylorN{R}) where {N, T, S, R} bb = TaylorModelN(convert(TaylorN{RR},b), 0..0, expansion_point(a), domain(a)) return (aa, bb) end -promote(b::TaylorN{R}, a::TaylorModelN{N,T,S}) where {N, T, S, R} = reverse( promote(a, b) ) +# promote(b::TaylorN{R}, a::TaylorModelN{N,T,S}) where {N, T, S, R} = reverse( promote(a, b) ) function promote(a::Taylor1{TaylorModelN{N,Interval{T},S}}, b::Taylor1{Interval{T}}) where {N, T<:Real, S<:Real} @@ -32,8 +32,8 @@ function promote(a::Taylor1{TaylorModelN{N,Interval{T},S}}, b::Taylor1{Interval{ end return (a, Taylor1(bTN)) end -promote(b::Taylor1{Interval{T}}, a::Taylor1{TaylorModelN{N,Interval{T},S}}) where - {N, T<:Real, S<:Real} = reverse( promote(a, b) ) +# promote(b::Taylor1{Interval{T}}, a::Taylor1{TaylorModelN{N,Interval{T},S}}) where +# {N, T<:Real, S<:Real} = reverse( promote(a, b) ) function promote(a::Taylor1{TaylorModelN{N,Interval{T},S}}, b::T) where {N, T<:Real, S<:Real} @@ -47,8 +47,8 @@ function promote(a::Taylor1{TaylorModelN{N,Interval{T},S}}, b::T) where end return (a, Taylor1(bTN)) end -promote(b::T, a::Taylor1{TaylorModelN{N,Interval{T},S}}) where - {N, T<:Real, S<:Real} = reverse( promote(a, b) ) +# promote(b::T, a::Taylor1{TaylorModelN{N,Interval{T},S}}) where +# {N, T<:Real, S<:Real} = reverse( promote(a, b) ) function promote(a::Taylor1{TaylorModelN{N,T,S}}, b::R) where {N, T<:Real, S<:Real, R<:Real} @@ -66,31 +66,26 @@ function promote(a::Taylor1{TaylorModelN{N,T,S}}, b::R) where bTN[1] += b return (Taylor1(aTN), Taylor1(bTN)) end -promote(b::R, a::Taylor1{TaylorModelN{N,T,S}}) where - {N, T<:Real, S<:Real, R<:Real} = reverse( promote(a, b) ) +# promote(b::R, a::Taylor1{TaylorModelN{N,T,S}}) where +# {N, T<:Real, S<:Real, R<:Real} = reverse( promote(a, b) ) -# function promote(a::Taylor1{TaylorModelN{N,T,S}}, b::Taylor1{S}) where {N,T<:Real,S<:Real} -# (a, Taylor1(TaylorModelN(interval(b), get_order(a), expansion_point(a), domain(a)), b.order)) -# end -# promote(b::Taylor1{Interval{T}}, a::Taylor1{TaylorModelN{N,Interval{T},S}}) where -# {N, T<:Real, S<:Real} = promote(a, b) for TM in tupleTMs - @eval promote(a::$TM{T,S}, b::T) where {T,S} = + @eval promote(a::$TM{T,S}, b::T) where {T,S<:Real} = (a, $(TM)(Taylor1([b], get_order(a)), zero(remainder(a)), expansion_point(a), domain(a))) - @eval promote(b::T, a::$TM{T,S}) where {T,S} = reverse( promote(a,b) ) + @eval promote(b::T, a::$TM{T,S}) where {T,S<:Real} = reverse( promote(a,b) ) # @eval promote(a::$TM{T,S}, b::S) where {T,S} = (a, $TM(Taylor1([convert(T, b)], get_order(a)), zero(remainder(a)), expansion_point(a), domain(a))) - @eval promote(b::S, a::$TM{T,S}) where {T,S} = reverse( promote(a,b) ) + # @eval promote(b::S, a::$TM{T,S}) where {T,S} = reverse( promote(a,b) ) # - @eval promote(a::$TM{T,S}, b::R) where {T,S,R} = promote(a, convert(S, b)) - @eval promote(b::R, a::$TM{T,S}) where {T,S,R} = reverse( promote(a,b) ) + # @eval promote(a::$TM{T,S}, b::R) where {T,S<:Real,R} = promote(a, convert(S, b)) + # @eval promote(b::R, a::$TM{T,S}) where {T,S,R} = reverse( promote(a,b) ) # @eval function promote(a::$TM{TaylorModelN{N,T,S},S}, b::T) where {N,T,S} a_pol0 = a.pol[0] tmN = TaylorModelN(b, get_order(a_pol0), expansion_point(a_pol0), domain(a_pol0)) return (a, $TM(Taylor1([tmN], get_order(a)), zero(remainder(a)), expansion_point(a), domain(a))) end - @eval promote(b::T, a::$TM{TaylorModelN{N,T,S},S}) where {N,T,S} = reverse( promote(a,b) ) + # @eval promote(b::T, a::$TM{TaylorModelN{N,T,S},S}) where {N,T,S} = reverse( promote(a,b) ) end diff --git a/src/show.jl b/src/show.jl index 0dd196e..4a66200 100644 --- a/src/show.jl +++ b/src/show.jl @@ -1,16 +1,17 @@ # show.jl -function showfull(io::IO, f::Union{TaylorModel1, RTaylorModel1, TaylorModelN}) - print(io, - """Taylor model of degree $(get_order(f)): - - x0: $(expansion_point(f)) - - I: $(domain(f)) - - p: $(polynomial(f)) - - Δ: $(remainder(f)) - """ - ) -end -showfull(x) = showfull(stdout::IO, x) +# Is the following really needed? +# function showfull(io::IO, f::Union{TaylorModel1, RTaylorModel1, TaylorModelN}) +# print(io, +# """Taylor model of degree $(get_order(f)): +# - x0: $(expansion_point(f)) +# - I: $(domain(f)) +# - p: $(polynomial(f)) +# - Δ: $(remainder(f)) +# """ +# ) +# end +# showfull(x) = showfull(stdout::IO, x) function show(io::IO, a::Union{TaylorModel1, RTaylorModel1, TaylorModelN}) if TaylorSeries._show_default[end] diff --git a/test/aqua.jl b/test/aqua.jl new file mode 100644 index 0000000..6ce2cbe --- /dev/null +++ b/test/aqua.jl @@ -0,0 +1,35 @@ +using Test +using TaylorModels +using Aqua + +@testset "Aqua tests (performance)" begin + # This tests that we don't accidentally run into + # https://github.com/JuliaLang/julia/issues/29393 + # Aqua.test_unbound_args(TaylorModels) + ua = Aqua.detect_unbound_args_recursively(TaylorModels) + @test length(ua) == 0 + + # See: https://github.com/SciML/OrdinaryDiffEq.jl/issues/1750 + # Test that we're not introducing method ambiguities across deps + ambs = Aqua.detect_ambiguities(TaylorModels; recursive = true) + pkg_match(pkgname, pkdir::Nothing) = false + pkg_match(pkgname, pkdir::AbstractString) = occursin(pkgname, pkdir) + filter!(x -> pkg_match("TaylorModels", pkgdir(last(x).module)), ambs) + for method_ambiguity in ambs + @show method_ambiguity + end + if VERSION < v"1.10.0-DEV" + @test length(ambs) == 0 + end +end + +@testset "Aqua tests (additional)" begin + Aqua.test_undefined_exports(TaylorModels) + Aqua.test_deps_compat(TaylorModels) + Aqua.test_stale_deps(TaylorModels) + Aqua.test_piracies(TaylorModels) + Aqua.test_unbound_args(TaylorModels) + Aqua.test_project_extras(TaylorModels) + Aqua.test_persistent_tasks(TaylorModels) +end + diff --git a/test/runtests.jl b/test/runtests.jl index 88fc301..8d72f8a 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -5,3 +5,4 @@ include("RTM1.jl") include("TMN.jl") include("shrink-wrapping.jl") include("validated_integ.jl") +include("aqua.jl")