From 4df8f6ba7fbd2c3f802ed86e4bccb064a0430b5e Mon Sep 17 00:00:00 2001 From: Joshua Lampert Date: Thu, 18 Dec 2025 13:44:04 +0100 Subject: [PATCH] run formatter --- src/array_partition.jl | 2 +- src/named_array_partition.jl | 4 ++-- test/basic_indexing.jl | 4 ++-- test/gpu/arraypartition_gpu.jl | 14 +++++++------- test/named_array_partition_tests.jl | 3 +-- test/partitions_test.jl | 10 +++++----- 6 files changed, 18 insertions(+), 19 deletions(-) diff --git a/src/array_partition.jl b/src/array_partition.jl index 08ff25b0..953011b9 100644 --- a/src/array_partition.jl +++ b/src/array_partition.jl @@ -636,4 +636,4 @@ end function Adapt.adapt_structure(to, ap::ArrayPartition) ArrayPartition(map(x -> Adapt.adapt(to, x), ap.x)...) -end \ No newline at end of file +end diff --git a/src/named_array_partition.jl b/src/named_array_partition.jl index 8fe0141b..fbaf3486 100644 --- a/src/named_array_partition.jl +++ b/src/named_array_partition.jl @@ -151,8 +151,8 @@ end #Overwrite ArrayInterface zeromatrix to work with NamedArrayPartitions & implicit solvers within OrdinaryDiffEq function ArrayInterface.zeromatrix(A::NamedArrayPartition) - B = ArrayPartition(A) - x = reduce(vcat,vec.(B.x)) + B = ArrayPartition(A) + x = reduce(vcat, vec.(B.x)) x .* x' .* false end diff --git a/test/basic_indexing.jl b/test/basic_indexing.jl index 273c2513..28b34451 100644 --- a/test/basic_indexing.jl +++ b/test/basic_indexing.jl @@ -182,8 +182,8 @@ u[1, [1, 3], 2] .= [7.0, 9.0] # 3D inner arrays (tensors) with ragged third dimension u = VectorOfArray([zeros(2, 1, n) for n in (2, 3)]) -@test size(view(u, :, :, :, 1)) == (2, 1, 2) -@test size(view(u, :, :, :, 2)) == (2, 1, 3) +@test size(view(u,:,:,:,1)) == (2, 1, 2) +@test size(view(u,:,:,:,2)) == (2, 1, 3) # assign into a slice of the second inner array using last index Int u[2, 1, :, 2] .= [7.0, 8.0, 9.0] @test vec(u.u[2][2, 1, :]) == [7.0, 8.0, 9.0] diff --git a/test/gpu/arraypartition_gpu.jl b/test/gpu/arraypartition_gpu.jl index 85b59893..384ac30b 100644 --- a/test/gpu/arraypartition_gpu.jl +++ b/test/gpu/arraypartition_gpu.jl @@ -24,13 +24,13 @@ b = ArrayPartition(([0.0f0] |> cu, [0.0f0] |> cu, [0.0f0] |> cu)) # Test adapt from ArrayPartition with CuArrays to ArrayPartition with CPU arrays -a = CuArray(Float64.([1., 2., 3., 4.])) -b = CuArray(Float64.([1., 2., 3., 4.])) +a = CuArray(Float64.([1.0, 2.0, 3.0, 4.0])) +b = CuArray(Float64.([1.0, 2.0, 3.0, 4.0])) part_a_gpu = ArrayPartition(a, b) part_a = adapt(Array{Float32}, part_a_gpu) -c = Float32.([1., 2., 3., 4.]) -d = Float32.([1., 2., 3., 4.]) +c = Float32.([1.0, 2.0, 3.0, 4.0]) +d = Float32.([1.0, 2.0, 3.0, 4.0]) part_b = ArrayPartition(c, d) @test part_a == part_b # Test equality @@ -42,7 +42,7 @@ for i in 1:length(part_a.x) @test typeof(sub_a) === typeof(sub_b) # Test type equality end -x = ArrayPartition((CUDA.zeros(2),CUDA.zeros(2))) +x = ArrayPartition((CUDA.zeros(2), CUDA.zeros(2))) @test ArrayInterface.zeromatrix(x) isa CuMatrix -@test size(ArrayInterface.zeromatrix(x)) == (4,4) -@test maximum(abs, x) == 0f0 +@test size(ArrayInterface.zeromatrix(x)) == (4, 4) +@test maximum(abs, x) == 0.0f0 diff --git a/test/named_array_partition_tests.jl b/test/named_array_partition_tests.jl index 069cd456..a3c1d952 100644 --- a/test/named_array_partition_tests.jl +++ b/test/named_array_partition_tests.jl @@ -10,12 +10,11 @@ using RecursiveArrayTools, ArrayInterface, Test @test typeof(x .+ x[1:end]) <: Vector # test broadcast precedence @test all(x .== x[1:end]) @test ArrayInterface.zeromatrix(x) isa Matrix - @test size(ArrayInterface.zeromatrix(x)) == (30,30) + @test size(ArrayInterface.zeromatrix(x)) == (30, 30) y = copy(x) @test zero(x, (10, 20)) == zero(x) # test that ignoring dims works @test typeof(zero(x)) <: NamedArrayPartition @test (y .*= 2).a[1] ≈ 2 # test in-place bcast - @test length(Array(x)) == 30 @test typeof(Array(x)) <: Array diff --git a/test/partitions_test.jl b/test/partitions_test.jl index 749f4b57..2e056e7c 100644 --- a/test/partitions_test.jl +++ b/test/partitions_test.jl @@ -329,13 +329,13 @@ end end # Test adapt on ArrayPartition from Float64 to Float32 arrays -a = Float64.([1., 2., 3., 4.]) -b = Float64.([1., 2., 3., 4.]) +a = Float64.([1.0, 2.0, 3.0, 4.0]) +b = Float64.([1.0, 2.0, 3.0, 4.0]) part_a_64 = ArrayPartition(a, b) part_a = adapt(Array{Float32}, part_a_64) -c = Float32.([1., 2., 3., 4.]) -d = Float32.([1., 2., 3., 4.]) +c = Float32.([1.0, 2.0, 3.0, 4.0]) +d = Float32.([1.0, 2.0, 3.0, 4.0]) part_b = ArrayPartition(c, d) @test part_a == part_b # Test equality of partitions @@ -345,4 +345,4 @@ for i in 1:length(part_a.x) sub_b = part_b.x[i] @test sub_a == sub_b # Test for value equality @test typeof(sub_a) === typeof(sub_b) # Test type equality -end \ No newline at end of file +end