Skip to content

Commit 3d08414

Browse files
p-zubietaararslan
authored andcommitted
Fix repeat for arrays of arrays
Ref #22747 (cherry picked from commit e8e475e)
1 parent 1dbe590 commit 3d08414

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

base/abstractarraymath.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ _reperr(s, n, N) = throw(ArgumentError("number of " * s * " repetitions " *
415415
n = inner[i]
416416
inner_indices[i] = (1:n) + ((c[i] - 1) * n)
417417
end
418-
R[inner_indices...] = A[c]
418+
fill!(view(R, inner_indices...), A[c])
419419
end
420420
end
421421

test/arrayops.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -793,6 +793,11 @@ end
793793
R = repeat(1:2, inner=(3,), outer=(2,))
794794
@test R == [1, 1, 1, 2, 2, 2, 1, 1, 1, 2, 2, 2]
795795

796+
# Arrays of arrays
797+
@test repeat([[1], [2]], inner=2) == [[1], [1], [2], [2]]
798+
@test repeat([[1], [2]], outer=2) == [[1], [2], [1], [2]]
799+
@test repeat([[1], [2]], inner=2, outer=2) == [[1], [1], [2], [2], [1], [1], [2], [2]]
800+
796801
@test size(repeat([1], inner=(0,))) == (0,)
797802
@test size(repeat([1], outer=(0,))) == (0,)
798803
@test size(repeat([1 1], inner=(0, 1))) == (0, 2)

0 commit comments

Comments
 (0)