From ca0f71310d7ceec473e9f0363ce4686b5aa195c4 Mon Sep 17 00:00:00 2001 From: mtfishman Date: Wed, 9 Apr 2025 10:46:18 -0400 Subject: [PATCH 1/4] Use SafeTestsets in tests --- Project.toml | 4 +++- test/lq.jl | 6 ++++++ test/qr.jl | 6 ++++++ test/runtests.jl | 42 ++++++++++++++++++++++-------------------- 4 files changed, 37 insertions(+), 21 deletions(-) diff --git a/Project.toml b/Project.toml index d8ea7ab4..78702565 100644 --- a/Project.toml +++ b/Project.toml @@ -18,6 +18,7 @@ ChainRulesCore = "1" ChainRulesTestUtils = "1" JET = "0.9" LinearAlgebra = "1" +SafeTestsets = "0.1" StableRNGs = "1" Test = "1" TestExtras = "0.2,0.3" @@ -28,10 +29,11 @@ julia = "1.10" Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" ChainRulesTestUtils = "cdddcdb0-9152-4a09-a978-84456f9df70a" JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b" +SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f" StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" TestExtras = "5ed8adda-3752-4e41-b88a-e8b09835ee3a" Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f" [targets] -test = ["Aqua", "JET", "Test", "TestExtras","ChainRulesCore", "ChainRulesTestUtils", "StableRNGs", "Zygote"] +test = ["Aqua", "JET", "SafeTestsets", "Test", "TestExtras","ChainRulesCore", "ChainRulesTestUtils", "StableRNGs", "Zygote"] diff --git a/test/lq.jl b/test/lq.jl index b1643080..10375e50 100644 --- a/test/lq.jl +++ b/test/lq.jl @@ -1,3 +1,9 @@ +using MatrixAlgebraKit +using Test +using TestExtras +using StableRNGs +using LinearAlgebra: diag, I + @testset "lq_compact! for T = $T" for T in (Float32, Float64, ComplexF32, ComplexF64) rng = StableRNG(123) m = 54 diff --git a/test/qr.jl b/test/qr.jl index 9fb96408..81c64f0e 100644 --- a/test/qr.jl +++ b/test/qr.jl @@ -1,3 +1,9 @@ +using MatrixAlgebraKit +using Test +using TestExtras +using StableRNGs +using LinearAlgebra: diag, I + @testset "qr_compact! and qr_null! for T = $T" for T in (Float32, Float64, ComplexF32, ComplexF64) rng = StableRNG(123) diff --git a/test/runtests.jl b/test/runtests.jl index 07a54125..c1abcb9c 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,44 +1,46 @@ -using MatrixAlgebraKit -using Test -using TestExtras -using ChainRulesTestUtils -using StableRNGs -using Aqua -using JET -using LinearAlgebra: LinearAlgebra, diag, Diagonal, I, isposdef, diagind, mul! -using MatrixAlgebraKit: diagview +## using MatrixAlgebraKit +## using Test +## using TestExtras +## using ChainRulesTestUtils +## using StableRNGs +## using Aqua +## using JET +## using LinearAlgebra: LinearAlgebra, diag, Diagonal, I, isposdef, diagind, mul! +## using MatrixAlgebraKit: diagview -@testset "QR / LQ Decomposition" begin +using SafeTestsets + +@safetestset "QR / LQ Decomposition" begin include("qr.jl") include("lq.jl") end -@testset "Singular Value Decomposition" begin +@safetestset "Singular Value Decomposition" begin include("svd.jl") end -@testset "Hermitian Eigenvalue Decomposition" begin +@safetestset "Hermitian Eigenvalue Decomposition" begin include("eigh.jl") end -@testset "General Eigenvalue Decomposition" begin +@safetestset "General Eigenvalue Decomposition" begin include("eig.jl") end -@testset "Schur Decomposition" begin +@safetestset "Schur Decomposition" begin include("schur.jl") end -@testset "Polar Decomposition" begin +@safetestset "Polar Decomposition" begin include("polar.jl") end -@testset "Image and Null Space" begin +@safetestset "Image and Null Space" begin include("orthnull.jl") end -@testset "ChainRules" verbose = true begin +@safetestset "ChainRules" verbose = true begin include("chainrules.jl") end -@testset "MatrixAlgebraKit.jl" begin - @testset "Code quality (Aqua.jl)" begin +@safetestset "MatrixAlgebraKit.jl" begin + @safetestset "Code quality (Aqua.jl)" begin Aqua.test_all(MatrixAlgebraKit) end - @testset "Code linting (JET.jl)" begin + @safetestset "Code linting (JET.jl)" begin JET.test_package(MatrixAlgebraKit; target_defined_modules=true) end end From c1bd501c8d8683c8618ed07781876ee278ff0fec Mon Sep 17 00:00:00 2001 From: mtfishman Date: Wed, 9 Apr 2025 11:17:01 -0400 Subject: [PATCH 2/4] Use SafeTestsets in tests --- test/chainrules.jl | 6 +++++- test/eig.jl | 7 +++++++ test/eigh.jl | 7 +++++++ test/orthnull.jl | 6 ++++++ test/polar.jl | 5 +++++ test/runtests.jl | 4 +++- test/schur.jl | 6 ++++++ test/svd.jl | 7 +++++++ 8 files changed, 46 insertions(+), 2 deletions(-) diff --git a/test/chainrules.jl b/test/chainrules.jl index a93c5270..ab895a4a 100644 --- a/test/chainrules.jl +++ b/test/chainrules.jl @@ -1,6 +1,10 @@ +using MatrixAlgebraKit +using Test +using TestExtras +using StableRNGs using ChainRulesCore, ChainRulesTestUtils, Zygote using MatrixAlgebraKit: diagview, TruncatedAlgorithm, PolarViaSVD -using LinearAlgebra: UpperTriangular, Diagonal, Hermitian +using LinearAlgebra: UpperTriangular, Diagonal, Hermitian, mul! function remove_svdgauge_depence!(ΔU, ΔVᴴ, U, S, Vᴴ; degeneracy_atol=MatrixAlgebraKit.default_pullback_gaugetol(S)) diff --git a/test/eig.jl b/test/eig.jl index da9c3961..d0dc13e3 100644 --- a/test/eig.jl +++ b/test/eig.jl @@ -1,3 +1,10 @@ +using MatrixAlgebraKit +using Test +using TestExtras +using StableRNGs +using LinearAlgebra: Diagonal +using MatrixAlgebraKit: diagview + @testset "eig_full! for T = $T" for T in (Float32, Float64, ComplexF32, ComplexF64) rng = StableRNG(123) m = 54 diff --git a/test/eigh.jl b/test/eigh.jl index 8967f665..5a3c5a8a 100644 --- a/test/eigh.jl +++ b/test/eigh.jl @@ -1,3 +1,10 @@ +using MatrixAlgebraKit +using Test +using TestExtras +using StableRNGs +using LinearAlgebra: LinearAlgebra, Diagonal, I +using MatrixAlgebraKit: diagview + @testset "eigh_full! for T = $T" for T in (Float32, Float64, ComplexF32, ComplexF64) rng = StableRNG(123) m = 54 diff --git a/test/orthnull.jl b/test/orthnull.jl index 7784fc82..0a93c593 100644 --- a/test/orthnull.jl +++ b/test/orthnull.jl @@ -1,3 +1,9 @@ +using MatrixAlgebraKit +using Test +using TestExtras +using StableRNGs +using LinearAlgebra: LinearAlgebra, I + @testset "left_orth and left_null for T = $T" for T in (Float32, Float64, ComplexF32, ComplexF64) rng = StableRNG(123) diff --git a/test/polar.jl b/test/polar.jl index 064e0e59..513654ea 100644 --- a/test/polar.jl +++ b/test/polar.jl @@ -1,3 +1,8 @@ +using MatrixAlgebraKit +using Test +using TestExtras +using StableRNGs +using LinearAlgebra: LinearAlgebra, I, isposdef using MatrixAlgebraKit: PolarViaSVD @testset "left_polar! for T = $T" for T in (Float32, Float64, ComplexF32, ComplexF64) diff --git a/test/runtests.jl b/test/runtests.jl index c1abcb9c..e1005ec7 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -32,15 +32,17 @@ end @safetestset "Image and Null Space" begin include("orthnull.jl") end -@safetestset "ChainRules" verbose = true begin +@safetestset "ChainRules" begin include("chainrules.jl") end @safetestset "MatrixAlgebraKit.jl" begin @safetestset "Code quality (Aqua.jl)" begin + using Aqua Aqua.test_all(MatrixAlgebraKit) end @safetestset "Code linting (JET.jl)" begin + using JET JET.test_package(MatrixAlgebraKit; target_defined_modules=true) end end diff --git a/test/schur.jl b/test/schur.jl index 05f952b5..71404e89 100644 --- a/test/schur.jl +++ b/test/schur.jl @@ -1,3 +1,9 @@ +using MatrixAlgebraKit +using Test +using TestExtras +using StableRNGs +using LinearAlgebra: I + @testset "schur_full! for T = $T" for T in (Float32, Float64, ComplexF32, ComplexF64) rng = StableRNG(123) m = 54 diff --git a/test/svd.jl b/test/svd.jl index 974957f0..b92c2e45 100644 --- a/test/svd.jl +++ b/test/svd.jl @@ -1,3 +1,10 @@ +using MatrixAlgebraKit +using Test +using TestExtras +using StableRNGs +using LinearAlgebra: LinearAlgebra, Diagonal, I, isposdef +using MatrixAlgebraKit: diagview + @testset "svd_compact! for T = $T" for T in (Float32, Float64, ComplexF32, ComplexF64) rng = StableRNG(123) m = 54 From 5e2b9ca651a43afa17795eff65a0bbee580e9972 Mon Sep 17 00:00:00 2001 From: mtfishman Date: Wed, 9 Apr 2025 11:18:50 -0400 Subject: [PATCH 3/4] Cleanup --- test/runtests.jl | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/test/runtests.jl b/test/runtests.jl index e1005ec7..1a0b59c3 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,13 +1,3 @@ -## using MatrixAlgebraKit -## using Test -## using TestExtras -## using ChainRulesTestUtils -## using StableRNGs -## using Aqua -## using JET -## using LinearAlgebra: LinearAlgebra, diag, Diagonal, I, isposdef, diagind, mul! -## using MatrixAlgebraKit: diagview - using SafeTestsets @safetestset "QR / LQ Decomposition" begin From b4917a94e2b746db8a144aad4cdcb3cf02f4f951 Mon Sep 17 00:00:00 2001 From: mtfishman Date: Wed, 9 Apr 2025 11:29:07 -0400 Subject: [PATCH 4/4] Fix missing import --- test/runtests.jl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/runtests.jl b/test/runtests.jl index 1a0b59c3..541c7da8 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -28,10 +28,12 @@ end @safetestset "MatrixAlgebraKit.jl" begin @safetestset "Code quality (Aqua.jl)" begin + using MatrixAlgebraKit using Aqua Aqua.test_all(MatrixAlgebraKit) end @safetestset "Code linting (JET.jl)" begin + using MatrixAlgebraKit using JET JET.test_package(MatrixAlgebraKit; target_defined_modules=true) end