diff --git a/src/array_partition.jl b/src/array_partition.jl index 89261f4b..4898b741 100644 --- a/src/array_partition.jl +++ b/src/array_partition.jl @@ -124,6 +124,12 @@ Base.ones(A::ArrayPartition, dims::NTuple{N, Int}) where {N} = ones(A) return :($res) end +## resize! +function Base.resize!(A::ArrayPartition, sizes::Tuple) + resize!.(A.x, sizes) + A +end + ## vector space operations for op in (:+, :-) diff --git a/test/partitions_test.jl b/test/partitions_test.jl index 3c0c2232..3b915c58 100644 --- a/test/partitions_test.jl +++ b/test/partitions_test.jl @@ -60,6 +60,10 @@ copyto!(p, c) @test c[1:5] == p.x[1] @test c[6:10] == p.x[2] +resize!(p, (6, 7)) +@test length(p.x[1]) == 6 +@test length(p.x[2]) == 7 + ## inference tests x = ArrayPartition([1, 2], [3.0, 4.0])