Skip to content

improve tests #429

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand All @@ -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 = ["Aqua", "FastBroadcast", "ForwardDiff", "Measurements", "NLsolve", "Pkg", "Random", "SafeTestsets", "SciMLBase", "SparseArrays", "StaticArrays", "StructArrays", "Test", "Unitful", "Zygote"]
2 changes: 1 addition & 1 deletion test/adjoints.jl
Original file line number Diff line number Diff line change
@@ -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])))
Expand Down
28 changes: 14 additions & 14 deletions test/copy_static_array_test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand All @@ -122,12 +122,12 @@ 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)))
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
end
10 changes: 9 additions & 1 deletion test/qa.jl
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
Loading