Skip to content

Commit

Permalink
Fix repeat for arrays of arrays
Browse files Browse the repository at this point in the history
Ref #22747
(cherry picked from commit e8e475e)
  • Loading branch information
pabloferz authored and ararslan committed Sep 13, 2017
1 parent 1dbe590 commit 3d08414
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion base/abstractarraymath.jl
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ _reperr(s, n, N) = throw(ArgumentError("number of " * s * " repetitions " *
n = inner[i]
inner_indices[i] = (1:n) + ((c[i] - 1) * n)
end
R[inner_indices...] = A[c]
fill!(view(R, inner_indices...), A[c])
end
end

Expand Down
5 changes: 5 additions & 0 deletions test/arrayops.jl
Original file line number Diff line number Diff line change
Expand Up @@ -793,6 +793,11 @@ end
R = repeat(1:2, inner=(3,), outer=(2,))
@test R == [1, 1, 1, 2, 2, 2, 1, 1, 1, 2, 2, 2]

# Arrays of arrays
@test repeat([[1], [2]], inner=2) == [[1], [1], [2], [2]]
@test repeat([[1], [2]], outer=2) == [[1], [2], [1], [2]]
@test repeat([[1], [2]], inner=2, outer=2) == [[1], [1], [2], [2], [1], [1], [2], [2]]

@test size(repeat([1], inner=(0,))) == (0,)
@test size(repeat([1], outer=(0,))) == (0,)
@test size(repeat([1 1], inner=(0, 1))) == (0, 2)
Expand Down

0 comments on commit 3d08414

Please sign in to comment.