You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#20635 changed the implementation of repeat for arrays to improve performance, but it now results in errors for Arrays of Arrays.
On julia version 0.6.0,
julia>repeat([[1,2], [3,4]]; inner=2)
ERROR: MethodError: Cannot `convert` an object of type Int64 to an object of type Array{Int64,1}
This may have arisen from a call to the constructor Array{Int64,1}(...),
since type constructors fall back to convert methods.
Stacktrace:
[1] setindex!(::Array{Array{Int64,1},1}, ::Array{Int64,1}, ::UnitRange{Int64}) at ./array.jl:573
[2] _repeat at ./abstractarraymath.jl:411 [inlined]
[3] #repeat#117(::Int64, ::Tuple{Int64}, ::Function, ::Array{Array{Int64,1},1}) at ./abstractarraymath.jl:366
[4] (::Base.#kw##repeat)(::Array{Any,1}, ::Base.#repeat, ::Array{Array{Int64,1},1}) at ./<missing>:0
The culprit seems to be trying to set a slice of the output array at once, using the behavior A[vector] = scalar to set multiple elements of A to the same scalar.
When A is an Array of Arrays and scalar is an Array, A[vector] = scalar behavior does not work, perhaps because it would be ambiguous with A[vector] = vector.
For example,
#20635 changed the implementation of repeat for arrays to improve performance, but it now results in errors for Arrays of Arrays.
On julia version 0.6.0,
The result should be
as it is in julia 0.5.
The error message is different for higher dimensional Arrays:
which should be
The culprit seems to be trying to set a slice of the output array at once, using the behavior
A[vector] = scalar
to set multiple elements of A to the same scalar.When A is an Array of Arrays and scalar is an Array,
A[vector] = scalar
behavior does not work, perhaps because it would be ambiguous withA[vector] = vector
.For example,
cannot be replaced with
for producing the behavior of
repeat([fill(1, 2,2), fill(2, 2,2)]; inner=2)
.Note that the behavior of the
outer
keyword works fine:as well as the behavior of indexable objects that are not AbstractArrays:
The text was updated successfully, but these errors were encountered: