You are trying to put a 0 into an array which expects Arrays as its
elements.
julia> bins = Array(Array, 5, 5)
5x5 Array{Array{T,N},2}:
#undef #undef #undef #undef #undef
#undef #undef #undef #undef #undef
#undef #undef #undef #undef #undef
#undef #undef #undef #undef #undef
#undef #undef #undef #undef #undef
julia> bins[1,1] = rand(2)
2-element Array{Float64,1}:
0.644859
0.549012
julia> bins
5x5 Array{Array{T,N},2}:
[0.644859323090488,0.5490118374607151] #undef #undef #undef #undef
#undef #undef #undef #undef #undef
#undef #undef #undef #undef #undef
#undef #undef #undef #undef #undef
#undef #undef #undef #undef #undef
On Friday, October 30, 2015 at 2:12:39 PM UTC+1, Cameron Zachreson wrote:
>
> Hello,
>
> Just started using Julia and I've come across an issue trying to create
> and append values to arrays of empty arrays.
>
> What I want to do is create a grid of empty arrays that can be filled with
> values associated with particle IDs for a molecular dynamics-style
> simulation. The trouble I'm having is that it does not seem possible to
> initialize the arrays so that they can be iteratively filled.
>
> here is an example of the problem:
>
> julia> bins = Array(Array, 5, 5)
>
>
> 5x5 Array{Array{T,N},2}:
>
> #undef #undef #undef #undef #undef
>
> #undef #undef #undef #undef #undef
>
> #undef #undef #undef #undef #undef
>
> #undef #undef #undef #undef #undef
>
> #undef #undef #undef #undef #undef
>
>
> julia> bins[1, 1] = 0
>
>
> ERROR: MethodError: `convert` has no method matching
> convert(::Type{Array{T,N}}, ::Int64)
>
> This may have arisen from a call to the constructor Array{T,N}(...),
>
> since type constructors fall back to convert methods.
>
> Closest candidates are:
>
> call{T}(::Type{T}, ::Any)
>
> convert(::Type{Array{T,N}}, ::SharedArray{T,N})
>
> convert{T,N}(::Type{Array{T,N}}, ::AbstractArray{T,N})
>
> ...
>
> in setindex! at array.jl:314
>
> I don't understand what the error message means, I have tried initializing
> with different datatypes, but it does not work. Any help would be
> appreciated.
>
> Cam
>
>
>
>