Skip to content

Commit

Permalink
Merge 2ed05ce into d87940f
Browse files Browse the repository at this point in the history
  • Loading branch information
lbenet committed Mar 14, 2024
2 parents d87940f + 2ed05ce commit 5dd9ac7
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 31 deletions.
5 changes: 4 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"]
2 changes: 0 additions & 2 deletions src/TaylorModels.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
29 changes: 12 additions & 17 deletions src/promotion.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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}
Expand All @@ -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}
Expand All @@ -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}
Expand All @@ -66,14 +66,9 @@ 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} =
Expand All @@ -82,15 +77,15 @@ for TM in tupleTMs
#
@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(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
23 changes: 12 additions & 11 deletions src/show.jl
Original file line number Diff line number Diff line change
@@ -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]
Expand Down
36 changes: 36 additions & 0 deletions test/aqua.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
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

nothing
1 change: 1 addition & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ include("RTM1.jl")
include("TMN.jl")
include("shrink-wrapping.jl")
include("validated_integ.jl")
include("aqua.jl")

0 comments on commit 5dd9ac7

Please sign in to comment.