Quantcast
Channel: First steps - JuliaLang
Viewing all articles
Browse latest Browse all 2795

Different behaviour during debugging and execution

$
0
0

@Volker wrote:

Somehow I get a different behaviour of the following code, but I don´t know why. As you can see from the REPL output during debugging the for-loop was executed successfully, but during execution not.

Does somebody have clue why the code lead to an error and why I get different behaviour during execution and debugging?

using Plots
plotly()


var_names = ["var1", "var2", "var3"]

# initialize regression matrices for training, validation and test
X1 =  rand(20, 3)
X2 =  rand(15, 3)
X3 = rand(10, 3)


function plot_space(list_data, var_names)
    num_dim = size(list_data[1], 2)
    num_plots = num_dim*(num_dim-1)/2

    for i in 1:num_dim
        for j in (i+1):num_dim
            if i==1 && j==2
                list_plots = [scatter(list_data[1][:, i], list_data[1][:, j], xlabel=var_names[i], ylabel=var_names[j])]
            else
                push!(list_plots, scatter(list_data[1][:, i], list_data[1][:, j], xlabel=var_names[i], ylabel=var_names[j]))
            end
            for k in 2:length(list_data)
                scatter!(list_plots[end], list_data[k][:, i], list_data[k][:, j]);
            end
            println("($i,$j)")
        end
    end
    return list_plots
end

list_plots = plot_space([X1, X2, X3], var_names)

Error Message during execution:
(1,2)
ERROR: LoadError: UndefVarError: list_plots not defined
Stacktrace:
[1] plot_space(::Array{Array{Float64,2},1}, ::Array{String,1}) at C:\Users\Volker\Julia_Files\space_analysis_test_example.jl:22
[2] top-level scope at none:0
in expression starting at C:\Users\Volker\Julia_Files\space_analysis_test_example.jl:33
julia>

Error Message during debugging:
julia> Juno.@enter plot_space([X1, X2, X3], var_names)
debug> (1,2)
(1,3)
(2,3)
ERROR: UndefVarError: list_plots not defined
Stacktrace:
[1] lookup_var at C:\Users\Volker.julia\packages\JuliaInterpreter\VHjfX\src\interpret.jl:9 [inlined]
[2] get_return(::JuliaInterpreter.Frame) at C:\Users\Volker.julia\packages\JuliaInterpreter\VHjfX\src\interpret.jl:64
[3] maybe_reset_frame!(::Any, ::JuliaInterpreter.Frame, ::Any, ::Bool) at C:\Users\Volker.julia\packages\JuliaInterpreter\VHjfX\src\commands.jl:327
[4] #debug_command#57(::Nothing, ::Function, ::Any, ::JuliaInterpreter.Frame, ::Symbol, ::Bool) at C:\Users\Volker.julia\packages\JuliaInterpreter\VHjfX\src\commands.jl:404
[5] debug_command(::Any, ::JuliaInterpreter.Frame, ::Symbol, ::Bool) at C:\Users\Volker.julia\packages\JuliaInterpreter\VHjfX\src\commands.jl:386
[6] (::getfield(Atom.JunoDebugger, Symbol("##51#53")){Bool})() at C:\Users\Volker.julia\packages\Atom\Wouyw\src\debugger\stepper.jl:144
[7] evalscope(::getfield(Atom.JunoDebugger, Symbol("##51#53")){Bool}) at C:\Users\Volker.julia\packages\Atom\Wouyw\src\debugger\stepper.jl:387
[8] startdebugging(::JuliaInterpreter.Frame, ::Bool) at C:\Users\Volker.julia\packages\Atom\Wouyw\src\debugger\stepper.jl:103
[9] top-level scope at C:\Users\Volker.julia\packages\Atom\Wouyw\src\debugger\stepper.jl:52

Posts: 4

Participants: 3

Read full topic


Viewing all articles
Browse latest Browse all 2795

Latest Images

Trending Articles



Latest Images