jonniedie / ComponentArrays.jl

Arrays with arbitrarily nested named components.
MIT License
287 stars 34 forks source link

UndefVarError: len not defined in `make_idx(data, pair::Pair, last_val)` #185

Open anandijain opened 1 year ago

anandijain commented 1 year ago
julia>     x = getsimulationresultsalldata(baseline_data, treatment_data);
ERROR: UndefVarError: `len` not defined
Stacktrace:
  [1] make_idx(data::Vector{Any}, pair::Pair{String, Matrix{Float64}}, last_val::Int64)
    @ ComponentArrays ~/.julia/packages/ComponentArrays/GsPr2/src/componentarray.jl:165
  [2] make_idx(data::Vector{Any}, nt::Dict{Symbol, Pair{String}}, last_val::Int64)
    @ ComponentArrays ~/.julia/packages/ComponentArrays/GsPr2/src/componentarray.jl:157
  [3] make_carray_args(A::Type{Vector}, nt::Dict{Symbol, Pair{String}})
    @ ComponentArrays ~/.julia/packages/ComponentArrays/GsPr2/src/componentarray.jl:147
  [4] make_carray_args(nt::Dict{Symbol, Pair{String}})
    @ ComponentArrays ~/.julia/packages/ComponentArrays/GsPr2/src/componentarray.jl:139
  [5] ComponentArray(nt::Dict{Symbol, Pair{String}})
    @ ComponentArrays ~/.julia/packages/ComponentArrays/GsPr2/src/componentarray.jl:63****

im on 0.13.6 i can't show the rest of the trace but the make_idx function does look wrong

function make_idx(data, pair::Pair, last_val)
    data, ax = make_idx(data, pair.second, last_val)
    return (data, ViewAxis(last_val:(last_val+len-1), Axis(pair.second)))
end
jonniedie commented 1 year ago

Oh, yeah, that's wrong. Would you mind giving me an example I could run on my end? It should work if we change that to

function make_idx(data, pair::Pair, last_val)
    data, ax = make_idx(data, pair.second, last_val)
    len = recursive_length(data)
    return (data, ViewAxis(last_val:(last_val+len-1), Axis(pair.second)))
end