Skip to content

Commit

Permalink
Add Aqua tests; CODECOV_TOKEN (#86)
Browse files Browse the repository at this point in the history
* Fix unbound type

* Use ⟸

* Add CODECOV_TOKEN

* Add aqua

* deps LinearAlgebra

* julia v1.10 vs v1.11
  • Loading branch information
JeffFessler committed May 19, 2024
1 parent ac0bef5 commit f4c3249
Show file tree
Hide file tree
Showing 13 changed files with 74 additions and 12 deletions.
19 changes: 16 additions & 3 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: CI

on:
create:
tags:
push:
branches:
- main
Expand Down Expand Up @@ -32,11 +34,15 @@ jobs:
coverage: true
steps:
- uses: actions/checkout@v4

# - name: "Set up Julia"
- uses: julia-actions/setup-julia@latest
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: actions/cache@v4

- name: Cache artifacts
uses: actions/cache@v4
env:
cache-name: cache-artifacts
with:
Expand All @@ -46,14 +52,21 @@ jobs:
${{ runner.os }}-test-${{ env.cache-name }}-
${{ runner.os }}-test-
${{ runner.os }}-
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-runtest@v1
# - name: "Unit Test"
- uses: julia-actions/julia-buildpkg@latest
- uses: julia-actions/julia-runtest@latest

# - name: "Cover"
- uses: julia-actions/julia-processcoverage@v1
if: matrix.coverage
- uses: codecov/codecov-action@v4
if: matrix.coverage
with:
file: lcov.info
fail_ci_if_error: false
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- uses: coverallsapp/github-action@master
if: matrix.coverage
with:
Expand Down
1 change: 1 addition & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Polynomials = "f27b6e38-b328-58d1-80ce-0feddd5e7a45"

[compat]
LinearAlgebra = "1"
Polynomials = "1, 2, 3, 4"
julia = "1.6"
6 changes: 3 additions & 3 deletions src/cauchy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ struct Cauchy{T,X,Y} <: AbstractMatrix{T}
y::Y

function Cauchy(
x::Union{NTuple{N,<:Tx}, AbstractArray{Tx}},
y::Union{NTuple{M,<:Ty}, AbstractArray{Ty}},
) where {N, M, Tx <: Number, Ty <: Number}
x::Union{NTuple{N,<:Tx} where {N}, AbstractArray{Tx}},
y::Union{NTuple{M,<:Ty} where {M}, AbstractArray{Ty}},
) where {Tx <: Number, Ty <: Number}
Base.require_one_based_indexing(x)
Base.require_one_based_indexing(y)
_cauchy_check(x, y)
Expand Down
4 changes: 2 additions & 2 deletions src/companion.jl
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,15 @@ function mul!(y::Vector, C::Companion, x::AbstractVector)
return y
end

# A <= B * C
# A B * C
function mul!(A::Matrix, B::AbstractMatrix, C::Companion)
@boundscheck (size(A) == (size(B,1), size(C,2)) && size(B, 2) == size(C,1)) ||
throw(DimensionMismatch("mul! arguments incompatible sizes"))
Base.require_one_based_indexing(B)
@views for j in 1:size(A,2)-1
@inbounds A[:,j] = B[:,j+1]
end
@inbounds mul!((@view A[:,end]), B, C.c, -1, 0) # A[:,end] <= - B * c
@inbounds mul!((@view A[:,end]), B, C.c, -1, 0) # A[:,end] - B * c
return A
end

Expand Down
2 changes: 1 addition & 1 deletion src/frobenius.jl
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ end

# Linear algebra

# 3-argument mul! mutates first argument: y <= F * x
# 3-argument mul! mutates first argument: y F * x
# *(F, x) = F * x derives from this automatically in Base
function mul!(y::Vector, F::Frobenius, x::AbstractVector)
Base.require_one_based_indexing(x)
Expand Down
1 change: 1 addition & 0 deletions test/Project.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[deps]
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
OffsetArrays = "6fe1bfb0-de20-5000-8ca7-80f57d26f881"
Polynomials = "f27b6e38-b328-58d1-80ce-0feddd5e7a45"
Expand Down
19 changes: 19 additions & 0 deletions test/aqua.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using SpecialMatrices: SpecialMatrices
import Aqua
using Test: @testset

@testset "aqua" begin
if VERSION < v"1.11"
Aqua.test_all(SpecialMatrices; ambiguities = false)
else
Aqua.test_all(SpecialMatrices)
end
end

#=
todo: 1 ambiguity in julia v1.10
mul!(A::Matrix, B::AbstractMatrix, C::SpecialMatrices.Companion)
SpecialMatrices/src/companion.jl:89
mul!(C::AbstractMatrix, A::LinearAlgebra.AbstractTriangular, B::AbstractMatrix)
LinearAlgebra/src/triangular.jl:691
=#
5 changes: 5 additions & 0 deletions test/cauchy.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# test/cauchy.jl

using SpecialMatrices: Cauchy
using Test: @test, @test_throws, @inferred

C = @inferred Cauchy(3)
@test 1 ./ C [2 3 4; 3 4 5; 4 5 6]
@test size(C) == (3,3)
Expand Down
3 changes: 3 additions & 0 deletions test/companion.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# test/companion.jl

using SpecialMatrices: Companion
using Test: @test, @test_throws, @inferred

import LinearAlgebra: mul!
using OffsetArrays: OffsetArray
import OffsetArrays # for no_offset_view
Expand Down
4 changes: 4 additions & 0 deletions test/frobenius.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# test/frobenius.jl

using SpecialMatrices: Frobenius
using Test: @test, @test_throws, @inferred
using LinearAlgebra: I
import LinearAlgebra: mul!

Expand Down
4 changes: 4 additions & 0 deletions test/hilbert.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# test/hilbert.jl

using SpecialMatrices: Hilbert, InverseHilbert
using LinearAlgebra: I, det, ishermitian, isposdef
using Test: @test, @test_throws, @inferred

n = 10
H = @inferred Hilbert(n)
@test H isa Hilbert
Expand Down
3 changes: 3 additions & 0 deletions test/kahan.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# test/kahan.jl

using SpecialMatrices: Kahan
using Test: @test, @inferred

m, n = 3, 5
A = Kahan(m, n, 0.5, 1e-3)

Expand Down
15 changes: 12 additions & 3 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using SpecialMatrices
using Test
using LinearAlgebra
using SpecialMatrices: SpecialMatrices
using Test: @test, @test_broken, @testset, detect_ambiguities

include("aqua.jl")

const files = (
"cauchy",
Expand All @@ -18,3 +19,11 @@ const files = (
include("$f.jl")
end
end

@testset "ambiguities" begin
if VERSION < v"1.11"
@test_broken isempty(detect_ambiguities(SpecialMatrices)) # see aqua.jl
else
@test isempty(detect_ambiguities(SpecialMatrices))
end
end

0 comments on commit f4c3249

Please sign in to comment.