Skip to content

Commit dcfedd8

Browse files
jverzanijishnub
andauthored
Jishnub aqua (#546)
* Test using Aqua v0.8 * immutable path for zero * remove comments --------- Co-authored-by: Jishnu Bhattacharya <[email protected]>
1 parent 0d1706e commit dcfedd8

File tree

3 files changed

+15
-14
lines changed

3 files changed

+15
-14
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ PolynomialsMakieCoreExt = "MakieCore"
2424
PolynomialsMutableArithmeticsExt = "MutableArithmetics"
2525

2626
[compat]
27-
Aqua = "0.6, 0.7"
27+
Aqua = "0.8"
2828
ChainRulesCore = "1"
2929
ChainRulesTestUtils = "1"
3030
DualNumbers = "0.6"

src/polynomial-container-types/immutable-dense-polynomial.jl

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,24 @@ Immutable is a bit of a misnomer, as using the `@set!` macro from `Setfield.jl`
1212
"""
1313
struct ImmutableDensePolynomial{B,T,X,N} <: AbstractDenseUnivariatePolynomial{B,T,X}
1414
coeffs::NTuple{N,T}
15-
function ImmutableDensePolynomial{B,T,X,N}(cs::NTuple{N}) where {B,N,T,X}
15+
function ImmutableDensePolynomial{B,T,X,N}(cs::Tuple{S,Vararg{S}}) where {B,N,T,X, S}
16+
m = length(cs)
17+
m > N && throw(ArgumentError("Tuple too large for N"))
18+
m < N && (cs = ntuple(i -> i <= m ? cs[i] : zero(T), Val(N)))
19+
new{B,T,Symbol(X),N}(T.(cs))
20+
end
21+
function ImmutableDensePolynomial{B,T,X,N}(cs::Tuple{}) where {B,N,T,X}
1622
new{B,T,Symbol(X),N}(cs)
1723
end
1824
end
1925

26+
2027
ImmutableDensePolynomial{B,T,X,N}(check::Type{Val{false}}, cs::NTuple{N,T}) where {B,N,T,X} =
2128
ImmutableDensePolynomial{B,T,X}(cs)
2229

2330
ImmutableDensePolynomial{B,T,X,N}(check::Type{Val{true}}, cs::NTuple{N,T}) where {B,N, T,X} =
2431
ImmutableDensePolynomial{B,T,X,N}(cs)
2532

26-
# tuple with mismatched size
27-
function ImmutableDensePolynomial{B,T,X,N}(xs::NTuple{M,S}) where {B,T,S,X,N,M}
28-
p = ImmutableDensePolynomial{B,S,X,M}(xs)
29-
convert(ImmutableDensePolynomial{B,T,X,N}, ImmutableDensePolynomial{B,T,X,M}(xs))
30-
end
31-
3233
# vector case with N
3334
function ImmutableDensePolynomial{B,T,X,N}(xs::AbstractVector{S}) where {B,T,S,X,N}
3435
ImmutableDensePolynomial{B,T,X,N}(ntuple(Base.Fix1(getindex, xs), Val(N)))
@@ -46,10 +47,13 @@ function ImmutableDensePolynomial{B,T,X,N}(c::S) where {B,T,X,N,S<:Scalar}
4647
cs = ntuple(i -> i == 1 ? T(c) : zero(T), Val(N))
4748
return ImmutableDensePolynomial{B,T,X,N}(cs)
4849
end
49-
ImmutableDensePolynomial{B,T,X}(::Val{false}, xs::NTuple{N,S}) where {B,T,S,X,N} = ImmutableDensePolynomial{B,T,X,N}(convert(NTuple{N,T}, xs))
50+
function ImmutableDensePolynomial{B,T,X}(::Val{false}, xs::Tuple{S,Vararg{S}}) where {B,T,S,X}
51+
N = length(xs)
52+
ImmutableDensePolynomial{B,T,X,N}(convert(NTuple{N,T}, xs))
53+
end
5054
ImmutableDensePolynomial{B,T,X}(xs::NTuple{N}) where {B,T,X,N} = ImmutableDensePolynomial{B,T,X,N}(convert(NTuple{N,T}, xs))
5155
ImmutableDensePolynomial{B,T}(xs::NTuple{N}, var::SymbolLike=Var(:x)) where {B,T,N} = ImmutableDensePolynomial{B,T,Symbol(var),N}(xs)
52-
ImmutableDensePolynomial{B}(xs::NTuple{N,T}, var::SymbolLike=Var(:x)) where {B,T,N} = ImmutableDensePolynomial{B,T,Symbol(var),N}(xs)
56+
ImmutableDensePolynomial{B}(xs::Tuple{T,Vararg{T}}, var::SymbolLike=Var(:x)) where {B,T} = ImmutableDensePolynomial{B,T,Symbol(var),length(xs)}(xs)
5357

5458
# abstract vector. Must eat order
5559
ImmutableDensePolynomial{B,T,X}(::Val{false}, xs::AbstractVector, order::Int=0) where {B,T,X} =

test/aqua.jl

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
11
using Aqua
22

3-
Aqua.test_all(Polynomials;
4-
unbound_args = false,
5-
stale_deps = false
6-
)
3+
Aqua.test_all(Polynomials)

0 commit comments

Comments
 (0)