Skip to content
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
2 changes: 1 addition & 1 deletion src/vector_of_array.jl
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ end

function Base.zero(VA::AbstractVectorOfArray)
val = copy(VA)
val.u = zero.(VA.u)
val.u .= zero.(VA.u)
return val
end

Expand Down
10 changes: 10 additions & 0 deletions test/interface_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -269,3 +269,13 @@ end
f3!(z, zz)
@test z == VectorOfArray([fill(4, SVector{2, Float64}), fill(2, SVector{2, Float64})])
@test (@allocated f3!(z, zz)) == 0

struct ImmutableVectorOfArray{T, N, A} <: AbstractVectorOfArray{T, N, A}
u::A # A <: AbstractArray{<: AbstractArray{T, N - 1}}
end

@testset "Base.zero does not assume mutable struct" begin
voa = ImmutableVectorOfArray{Float64, 2, Vector{Vector{Float64}}}([ones(3), 2ones(3)])
zvoa = zero(voa)
@test zvoa.u[1] == zvoa.u[2] == zeros(3)
end
2 changes: 1 addition & 1 deletion test/linalg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@ mat = Array(va)
@test all(va'[i] == mat'[i] for i in eachindex(mat'))
@test Array(va') == mat'

@test !ArrayInterface.issingular(VectorOfArray([rand(2),rand(2)]))
@test !ArrayInterface.issingular(VectorOfArray([rand(2), rand(2)]))
1 change: 0 additions & 1 deletion test/partitions_test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ _scalar_op(y) = y + 1
_broadcast_wrapper(y) = _scalar_op.(y)
# Issue #8
@inferred _broadcast_wrapper(x)
@test_broken @inferred _broadcast_wrapper(y)

# Testing map
@test map(x -> x^2, x) == ArrayPartition(x.x[1] .^ 2, x.x[2] .^ 2)
Expand Down
Loading