From b959343ac192ff5831104c565e12f30e9fe673b7 Mon Sep 17 00:00:00 2001 From: Pablo Zubieta Date: Mon, 10 Jul 2017 18:52:40 -0500 Subject: [PATCH] Fix repeat for arrays of arrays Ref #22747 (cherry picked from commit e8e475e6651d43c3c46442fceee396e32cfd1ed7) --- base/abstractarraymath.jl | 2 +- test/arrayops.jl | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/base/abstractarraymath.jl b/base/abstractarraymath.jl index 0430293b46737..726c8c06ae851 100644 --- a/base/abstractarraymath.jl +++ b/base/abstractarraymath.jl @@ -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 diff --git a/test/arrayops.jl b/test/arrayops.jl index dc4c60675ba45..cfe5a5c34c036 100644 --- a/test/arrayops.jl +++ b/test/arrayops.jl @@ -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)