From e3e3bd76f0d1899488cc96975741b8befa7cfb53 Mon Sep 17 00:00:00 2001 From: Erik Faulhaber <44124897+efaulhaber@users.noreply.github.com> Date: Tue, 14 Oct 2025 17:54:03 +0200 Subject: [PATCH] Implement `Base.resize!` for `ArrayPartition`s --- src/array_partition.jl | 6 ++++++ test/partitions_test.jl | 4 ++++ 2 files changed, 10 insertions(+) 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])