From 59ae7b8b7753b312b9b13f786c771cc45a51ebe3 Mon Sep 17 00:00:00 2001 From: oscarddssmith Date: Fri, 28 Mar 2025 11:37:54 -0400 Subject: [PATCH 1/2] improve tests --- Project.toml | 6 +++--- test/adjoints.jl | 2 +- test/copy_static_array_test.jl | 28 ++++++++++++++-------------- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Project.toml b/Project.toml index b07b08f2..a4c6c955 100644 --- a/Project.toml +++ b/Project.toml @@ -51,12 +51,12 @@ LinearAlgebra = "1.10" Measurements = "2.3" MonteCarloMeasurements = "1.1" NLsolve = "4.5" -OrdinaryDiffEq = "6.62" Pkg = "1" Random = "1" RecipesBase = "1.1" ReverseDiff = "1.15" SafeTestsets = "0.1" +SciMLBase = "2" SparseArrays = "1.10" StaticArrays = "1.6" StaticArraysCore = "1.4" @@ -77,10 +77,10 @@ ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210" Measurements = "eff96d63-e80a-5855-80a2-b1b0885c5ab7" MonteCarloMeasurements = "0987c9cc-fe09-11e8-30f0-b96dd679fdca" NLsolve = "2774e3e8-f4cf-5e23-947b-6d7e65073b56" -OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed" Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f" +SciMLBase = "0bca4576-84f4-4d90-8ffe-ffa030f20462" SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" StructArrays = "09ab397b-f2b6-538f-b94a-2f83cf4a842a" @@ -90,4 +90,4 @@ Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d" Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f" [targets] -test = ["SafeTestsets", "Aqua", "FastBroadcast", "SparseArrays", "ForwardDiff", "NLsolve", "OrdinaryDiffEq", "Pkg", "Test", "Unitful", "Random", "StaticArrays", "StructArrays", "Zygote", "Measurements"] +test = ["SafeTestsets", "Aqua", "FastBroadcast", "SparseArrays", "ForwardDiff", "NLsolve", "Pkg", "Test", "Unitful", "Random", "SciMLBase", "StaticArrays", "StructArrays", "Zygote", "Measurements"] diff --git a/test/adjoints.jl b/test/adjoints.jl index e5a1fc50..2fd48fd1 100644 --- a/test/adjoints.jl +++ b/test/adjoints.jl @@ -1,5 +1,5 @@ using RecursiveArrayTools, Zygote, ForwardDiff, Test -using OrdinaryDiffEq +using SciMLBase function loss(x) sum(abs2, Array(VectorOfArray([x .* i for i in 1:5]))) diff --git a/test/copy_static_array_test.jl b/test/copy_static_array_test.jl index de0132ce..43539dcf 100644 --- a/test/copy_static_array_test.jl +++ b/test/copy_static_array_test.jl @@ -87,33 +87,33 @@ a[1] *= 2 a = [SVector(0.0) for _ in 1:2] a_voa = VectorOfArray(a) b_voa = copy(a_voa) -a_voa[1] = SVector(1.0) -a_voa[2] = SVector(1.0) +a_voa[:, 1] = SVector(1.0) +a_voa[:, 2] = SVector(1.0) @. b_voa = a_voa -@test b_voa[1] == a_voa[1] -@test b_voa[2] == a_voa[2] +@test b_voa[:, 1] == a_voa[1] +@test b_voa[:, 2] == a_voa[2] a = [SVector(0.0) for _ in 1:2] a_voa = VectorOfArray(a) a_voa .= 1.0 -@test a_voa[1] == SVector(1.0) -@test a_voa[2] == SVector(1.0) +@test a_voa[:, 1] == SVector(1.0) +@test a_voa[:, 2] == SVector(1.0) # Broadcasting when SVector{N} where N > 1 a = [SVector(0.0, 0.0) for _ in 1:2] a_voa = VectorOfArray(a) b_voa = copy(a_voa) -a_voa[1] = SVector(1.0, 1.0) -a_voa[2] = SVector(1.0, 1.0) +a_voa[:, 1] = SVector(1.0, 1.0) +a_voa[:, 2] = SVector(1.0, 1.0) @. b_voa = a_voa -@test b_voa[1] == a_voa[1] -@test b_voa[2] == a_voa[2] +@test b_voa[:, 1] == a_voa[:, 1] +@test b_voa[:, 2] == a_voa[:, 2] a = [SVector(0.0, 0.0) for _ in 1:2] a_voa = VectorOfArray(a) a_voa .= 1.0 -@test a_voa[1] == SVector(1.0, 1.0) -@test a_voa[2] == SVector(1.0, 1.0) +@test a_voa[:, 1] == SVector(1.0, 1.0) +@test a_voa[:, 2] == SVector(1.0, 1.0) #Broadcast Copy of StructArray x = StructArray{SVector{2, Float64}}((randn(2), randn(2))) @@ -122,7 +122,7 @@ vx2 = copy(vx) .+ 1 ans = vx .+ vx2 @test ans.u isa StructArray -# check that Base.similar(VectorOfArray{<:StaticArray}) returns the +# check that Base.similar(VectorOfArray{<:StaticArray}) returns the # same type as the original VectorOfArray x_staticvector = [SVector(0.0, 0.0) for _ in 1:2] x_structarray = StructArray{SVector{2, Float64}}((randn(2), randn(2))) @@ -130,4 +130,4 @@ x_mutablefv = [MutableFV(1.0, 2.0)] x_immutablefv = [ImmutableFV(1.0, 2.0)] for vec in [x_staticvector, x_structarray, x_mutablefv, x_immutablefv] @test typeof(similar(VectorOfArray(vec))) === typeof(VectorOfArray(vec)) -end \ No newline at end of file +end From c0468b6e8c2fb06efd2ad1b2dd6c97c286949851 Mon Sep 17 00:00:00 2001 From: oscarddssmith Date: Fri, 28 Mar 2025 13:12:41 -0400 Subject: [PATCH 2/2] test that downstream packages aren't added --- Project.toml | 2 +- test/qa.jl | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Project.toml b/Project.toml index a4c6c955..bd393da9 100644 --- a/Project.toml +++ b/Project.toml @@ -90,4 +90,4 @@ Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d" Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f" [targets] -test = ["SafeTestsets", "Aqua", "FastBroadcast", "SparseArrays", "ForwardDiff", "NLsolve", "Pkg", "Test", "Unitful", "Random", "SciMLBase", "StaticArrays", "StructArrays", "Zygote", "Measurements"] +test = ["Aqua", "FastBroadcast", "ForwardDiff", "Measurements", "NLsolve", "Pkg", "Random", "SafeTestsets", "SciMLBase", "SparseArrays", "StaticArrays", "StructArrays", "Test", "Unitful", "Zygote"] diff --git a/test/qa.jl b/test/qa.jl index 29323ac1..e061435f 100644 --- a/test/qa.jl +++ b/test/qa.jl @@ -1,4 +1,12 @@ -using RecursiveArrayTools, Aqua +using RecursiveArrayTools, Aqua, Pkg + +# yes this is horrible, we'll fix it when Pkg or Base provides a decent API +manifest = Pkg.Types.EnvCache().manifest +# these are good sentinels to test whether someone has added a heavy SciML package to the test deps +if haskey(manifest.deps, "NonlinearSolveBase") || haskey(manifest.deps, "DiffEqBase") + error("Don't put Downstream Packages in non Downstream CI") +end + @testset "Aqua" begin Aqua.find_persistent_tasks_deps(RecursiveArrayTools) Aqua.test_ambiguities(RecursiveArrayTools; recursive = false, broken = true)