Assigning an array works in REPL but not in .jl script run from terminal

I want to include an assignment of a multidimensional array (an array of arrays) to a variable in a script and run that script from the terminal.

I try the assignment in REPL, which works flawlessly. Assigning the first element:

julia> w=Array[[Array[[1.0,0.0,0.0],[0.0],[0.0],[0.0,0.0,-1.0]]]]
1-element Array{Array{T,N},1}:
Array[[1.0,0.0,0.0],[0.0],[0.0],[0.0,0.0,-1.0]]

But when I put exactly the same syntax, namely

w=Array[[Array[[1.0,0.0,0.0],[0.0],[0.0],[0.0,0.0,-1.0]]]]

in a .jl scrip and run it from the terminal i get

~/Julia/Julia_projects/Kalman $ julia test_vectors_2.jl
WARNING: [a] concatenation is deprecated; use collect(a) instead
in depwarn at deprecated.jl:73
in oldstyle_vcat_warning at ./abstractarray.jl:29
in vect at abstractarray.jl:32
in include at ./boot.jl:261
in include_from_node1 at ./loading.jl:333
in process_options at ./client.jl:280
in _start at ./client.jl:378
while loading /home/philip/Julia/Julia_projects/Kalman/test_vectors_2.jl, in expression starting on line 1

What is wrong?

The two shows exactly the same result. You must have hit the same depwarn before so it was not printed again.

Note that the Arrays are not completely (concretely) typed, as indicated by the parameters T, N. What happens of you remove the words “Array”?

I finally found the right syntax:

(The goal was to create a one dimensional array of arrays to which I can add alements)

This works without warnings in both REPL and run from a script in a Bash terminal:

Testvector    =             Vector in e-frame    lat [degreees]     lon [degrees]    Expected result in n-frame
                    -----------------    --------------    -------------    --------------------------    
w=        Array[    Array[        [1.0,0.0,0.0],         [0.0],        [0.0],        [0.0,0.0,-1.0]            ]]

Add elements to the vector
push!(w, [Array[ [1.0,0.0,0.0], [0.0], [90.0], [0.0,-1.0,0.0] ]])
push!(w, [Array[ [1.0,0.0,0.0], [0.0], [180.0], [0.0,0.0,1.0] ]])
push!(w, [Array[ [1.0,0.0,0.0], [0.0], [-90.0], [0.0,1.0,0.0] ]])
push!(w, [Array[ [1.0,0.0,0.0], [0.0], [-180.0], [0.0,0.0,1.0] ]])

Are you using Julia 0.4? If so, I suggest you upgrade to 0.5.

The correct way to create an empty array of arrays of e.g. Float64s and then add things to it is:

julia> w = Vector{Float64}[]
0-element Array{Array{Float64,1},1}

julia> push!(w, [1.0,0.0,0.0], [0.0], [90.0], [0.0,-1.0,0.0])
4-element Array{Array{Float64,1},1}:
 [1.0,0.0,0.0]
 [0.0]
 [90.0]
 [0.0,-1.0,0.0]

In Julia 0.5 (but not in 0.4), you can create the array directly using the syntax that you would expect:

julia> w = [ [1.0,0.0,0.0], [0.0], [90.0], [0.0,-1.0,0.0] ]
4-element Array{Array{Float64,1},1}:
 [1.0,0.0,0.0]
 [0.0]
 [90.0]
 [0.0,-1.0,0.0]

Note that in both cases, you do not get Array{T,N} (i.e. an Array for which the Julia compiler does not know the types contained in it), which will (usually) lead to poor performance.

I was on

$ julia -v
julia version 0.4.8-pre

It is comforting that the syntax in Julia 0.5 is more what you would expect.

I use git for my updates and on your recommendation i did

git branch -r
git checkout release-0.5
git pull
git make

Now I am on version

$ julia -v
julia version 0.5.1-pre

Thanks!