Skip to content

Commit 3c597f7

Browse files
committed
Implement Base.resize! for ArrayPartitions
1 parent ec2ee49 commit 3c597f7

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/array_partition.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,12 @@ Base.ones(A::ArrayPartition, dims::NTuple{N, Int}) where {N} = ones(A)
124124
return :($res)
125125
end
126126

127+
## resize!
128+
function Base.resize!(A::ArrayPartition, sizes::Tuple)
129+
resize!.(A.x, Ref(sizes))
130+
A
131+
end
132+
127133
## vector space operations
128134

129135
for op in (:+, :-)

test/partitions_test.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ copyto!(p, c)
6060
@test c[1:5] == p.x[1]
6161
@test c[6:10] == p.x[2]
6262

63+
resize!(p, (6, 7))
64+
@test length(p.x[1]) == 6
65+
@test length(p.x[2]) == 7
66+
6367
## inference tests
6468

6569
x = ArrayPartition([1, 2], [3.0, 4.0])

0 commit comments

Comments
 (0)