Skip to content
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

Add Aqua checks #166

Merged
merged 5 commits into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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
2 changes: 1 addition & 1 deletion src/evaluate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
35 changes: 15 additions & 20 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,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
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
35 changes: 35 additions & 0 deletions test/aqua.jl
Original file line number Diff line number Diff line change
@@ -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

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")
Loading