diff --git a/.github/dependabot.yml b/.github/dependabot.yml index b3a0706..eb41b37 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -9,7 +9,7 @@ updates: - "/" - "/docs" - "/test" - - "/test/nopre" + - "/test/qa" schedule: interval: "daily" groups: diff --git a/.github/workflows/Tests.yml b/.github/workflows/Tests.yml index d3c0f28..5d3a530 100644 --- a/.github/workflows/Tests.yml +++ b/.github/workflows/Tests.yml @@ -20,22 +20,5 @@ concurrency: jobs: tests: - name: "Tests" - strategy: - fail-fast: false - matrix: - version: - - "1" - - "lts" - - "pre" - group: - - Core - - nopre - exclude: - - version: "pre" - group: nopre - uses: "SciML/.github/.github/workflows/tests.yml@v1" - with: - julia-version: "${{ matrix.version }}" - group: "${{ matrix.group }}" + uses: "SciML/.github/.github/workflows/grouped-tests.yml@v1" secrets: "inherit" diff --git a/test/Project.toml b/test/Project.toml index be67af0..3596791 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -1,17 +1,15 @@ [deps] -Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" -Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f" +SciMLTesting = "09d9d899-5365-40a9-917a-5f67fddea283" SparseBandedMatrices = "bd59d7e1-4699-4102-944e-d05209cb92aa" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [compat] -Aqua = "0.8" LinearAlgebra = "1" -Pkg = "1" Random = "1" SafeTestsets = "0.1" +SciMLTesting = "1" SparseBandedMatrices = "1.3.0" Test = "1" diff --git a/test/constructors.jl b/test/constructors.jl new file mode 100644 index 0000000..bbf2885 --- /dev/null +++ b/test/constructors.jl @@ -0,0 +1,14 @@ +using SparseBandedMatrices +using Test + +@testset "Constructors" begin + A = SparseBandedMatrix{Float64}(undef, 5, 5) + A[1, 1] = 2 + @test A[1, 1] == 2.0 + A[4, 1] = 0 + @test A[4, 1] == 0.0 + A[1, 3] = 5 + @test A[1, 3] == 5.0 + + @test size(A) == (5, 5) +end diff --git a/test/division.jl b/test/division.jl new file mode 100644 index 0000000..34dd15b --- /dev/null +++ b/test/division.jl @@ -0,0 +1,33 @@ +using SparseBandedMatrices, Random +using Test + +@testset "Division" begin + dim = 5000 + x = rand(10:75) + diag_vals = Vector{Vector{Float64}}(undef, x) + diag_locs = randperm(dim * 2 - 1)[1:x] + for j in 1:x + diag_vals[j] = rand(min(diag_locs[j], 2 * dim - diag_locs[j])) + end + + x_butterfly = SparseBandedMatrix{Float64}(diag_locs, diag_vals, dim, dim) + x_dense = copy(x_butterfly) + + y = rand(dim, dim) + z = zeros(dim, dim) + + @test isapprox(x_dense / y, x_butterfly / y) + @test isapprox(y / x_dense, y / x_butterfly) + + y = rand(10:75) + diag_vals = Vector{Vector{Float64}}(undef, y) + diag_locs = randperm(dim * 2 - 1)[1:y] + for j in 1:y + diag_vals[j] = rand(min(diag_locs[j], 2 * dim - diag_locs[j])) + end + + y_butterfly = SparseBandedMatrix{Float64}(diag_locs, diag_vals, dim, dim) + y_dense = copy(y_butterfly) + + @test isapprox(x_butterfly / y_butterfly, x_dense / y_dense) +end diff --git a/test/multiplication.jl b/test/multiplication.jl new file mode 100644 index 0000000..5399b66 --- /dev/null +++ b/test/multiplication.jl @@ -0,0 +1,33 @@ +using SparseBandedMatrices, Random +using Test + +@testset "Multiplication" begin + dim = 5000 + x = rand(10:75) + diag_vals = Vector{Vector{Float64}}(undef, x) + diag_locs = randperm(dim * 2 - 1)[1:x] + for j in 1:x + diag_vals[j] = rand(min(diag_locs[j], 2 * dim - diag_locs[j])) + end + + x_butterfly = SparseBandedMatrix{Float64}(diag_locs, diag_vals, dim, dim) + x_dense = copy(x_butterfly) + + y = rand(dim, dim) + z = zeros(dim, dim) + + @test isapprox(x_dense * y, x_butterfly * y) + @test isapprox(y * x_dense, y * x_butterfly) + + y = rand(10:75) + diag_vals = Vector{Vector{Float64}}(undef, y) + diag_locs = randperm(dim * 2 - 1)[1:y] + for j in 1:y + diag_vals[j] = rand(min(diag_locs[j], 2 * dim - diag_locs[j])) + end + + y_butterfly = SparseBandedMatrix{Float64}(diag_locs, diag_vals, dim, dim) + y_dense = copy(y_butterfly) + + @test isapprox(x_butterfly * y_butterfly, x_dense * y_dense) +end diff --git a/test/nopre/runtests.jl b/test/nopre/runtests.jl deleted file mode 100644 index 54763c4..0000000 --- a/test/nopre/runtests.jl +++ /dev/null @@ -1,5 +0,0 @@ -using Test - -@testset "nopre tests" begin - include("jet.jl") -end diff --git a/test/qa.jl b/test/qa.jl deleted file mode 100644 index 0dd74bf..0000000 --- a/test/qa.jl +++ /dev/null @@ -1,4 +0,0 @@ -using SparseBandedMatrices, Aqua -@testset "Aqua" begin - Aqua.test_all(SparseBandedMatrices; ambiguities = (recursive = false,)) -end diff --git a/test/nopre/Project.toml b/test/qa/Project.toml similarity index 50% rename from test/nopre/Project.toml rename to test/qa/Project.toml index d8b7042..30f25fd 100644 --- a/test/nopre/Project.toml +++ b/test/qa/Project.toml @@ -1,11 +1,20 @@ [deps] +Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" +SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f" +SciMLTesting = "09d9d899-5365-40a9-917a-5f67fddea283" SparseBandedMatrices = "bd59d7e1-4699-4102-944e-d05209cb92aa" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" +[sources] +SparseBandedMatrices = {path = "../.."} + [compat] +Aqua = "0.8" JET = "0.9, 0.10, 0.11" LinearAlgebra = "1" -SparseBandedMatrices = "1.3.0" +SafeTestsets = "0.1" +SciMLTesting = "1" Test = "1" +julia = "1.10" diff --git a/test/nopre/jet.jl b/test/qa/qa.jl similarity index 86% rename from test/nopre/jet.jl rename to test/qa/qa.jl index 7ef397d..d0ebf4a 100644 --- a/test/nopre/jet.jl +++ b/test/qa/qa.jl @@ -1,4 +1,8 @@ -using SparseBandedMatrices, JET, LinearAlgebra +using SparseBandedMatrices, Aqua, JET, LinearAlgebra, Test + +@testset "Aqua" begin + Aqua.test_all(SparseBandedMatrices; ambiguities = (recursive = false,)) +end @testset "JET static analysis" begin # Test that there are no unresolved dispatch errors in key functions diff --git a/test/runtests.jl b/test/runtests.jl index 709ae97..a18a7cc 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,95 +1,2 @@ -using SafeTestsets, Test, Pkg - -const GROUP = get(ENV, "GROUP", "All") - -@testset "SparseBandedMatrices" begin - if GROUP == "All" || GROUP == "Core" - @safetestset "Quality Assurance" include("qa.jl") - @safetestset "Interface Compatibility" include("interface.jl") - - @safetestset "Constructors" begin - using SparseBandedMatrices - - A = SparseBandedMatrix{Float64}(undef, 5, 5) - A[1, 1] = 2 - @test A[1, 1] == 2.0 - A[4, 1] = 0 - @test A[4, 1] == 0.0 - A[1, 3] = 5 - @test A[1, 3] == 5.0 - - @test size(A) == (5, 5) - end - - @safetestset "Multiplication" begin - using SparseBandedMatrices, Random - dim = 5000 - x = rand(10:75) - diag_vals = Vector{Vector{Float64}}(undef, x) - diag_locs = randperm(dim * 2 - 1)[1:x] - for j in 1:x - diag_vals[j] = rand(min(diag_locs[j], 2 * dim - diag_locs[j])) - end - - x_butterfly = SparseBandedMatrix{Float64}(diag_locs, diag_vals, dim, dim) - x_dense = copy(x_butterfly) - - y = rand(dim, dim) - z = zeros(dim, dim) - - @test isapprox(x_dense * y, x_butterfly * y) - @test isapprox(y * x_dense, y * x_butterfly) - - y = rand(10:75) - diag_vals = Vector{Vector{Float64}}(undef, y) - diag_locs = randperm(dim * 2 - 1)[1:y] - for j in 1:y - diag_vals[j] = rand(min(diag_locs[j], 2 * dim - diag_locs[j])) - end - - y_butterfly = SparseBandedMatrix{Float64}(diag_locs, diag_vals, dim, dim) - y_dense = copy(y_butterfly) - - @test isapprox(x_butterfly * y_butterfly, x_dense * y_dense) - end - - @safetestset "Division" begin - using SparseBandedMatrices, Random - dim = 5000 - x = rand(10:75) - diag_vals = Vector{Vector{Float64}}(undef, x) - diag_locs = randperm(dim * 2 - 1)[1:x] - for j in 1:x - diag_vals[j] = rand(min(diag_locs[j], 2 * dim - diag_locs[j])) - end - - x_butterfly = SparseBandedMatrix{Float64}(diag_locs, diag_vals, dim, dim) - x_dense = copy(x_butterfly) - - y = rand(dim, dim) - z = zeros(dim, dim) - - @test isapprox(x_dense / y, x_butterfly / y) - @test isapprox(y / x_dense, y / x_butterfly) - - y = rand(10:75) - diag_vals = Vector{Vector{Float64}}(undef, y) - diag_locs = randperm(dim * 2 - 1)[1:y] - for j in 1:y - diag_vals[j] = rand(min(diag_locs[j], 2 * dim - diag_locs[j])) - end - - y_butterfly = SparseBandedMatrix{Float64}(diag_locs, diag_vals, dim, dim) - y_dense = copy(y_butterfly) - - @test isapprox(x_butterfly / y_butterfly, x_dense / y_dense) - end - end - - if GROUP == "All" || GROUP == "nopre" - Pkg.activate(joinpath(@__DIR__, "nopre")) - Pkg.develop(PackageSpec(path = joinpath(@__DIR__, ".."))) - Pkg.instantiate() - @safetestset "JET Static Analysis" include("nopre/jet.jl") - end -end +using SciMLTesting +run_tests() diff --git a/test/test_groups.toml b/test/test_groups.toml new file mode 100644 index 0000000..1fe84cd --- /dev/null +++ b/test/test_groups.toml @@ -0,0 +1,5 @@ +[Core] +versions = ["lts", "1", "pre"] + +[QA] +versions = ["lts", "1"]