|
13 | 13 | ### Constructors |
14 | 14 | ############################################################################################ |
15 | 15 |
|
16 | | -# constuct an empty table |
17 | | -function ParameterTable(; |
| 16 | +# construct a dictionary with the default partable columns |
| 17 | +# optionally pre-allocate data for nrows |
| 18 | +empty_partable_columns(nrows::Integer = 0) = Dict{Symbol, Vector}( |
| 19 | + :from => fill(Symbol(), nrows), |
| 20 | + :parameter_type => fill(Symbol(), nrows), |
| 21 | + :to => fill(Symbol(), nrows), |
| 22 | + :free => fill(true, nrows), |
| 23 | + :value_fixed => fill(NaN, nrows), |
| 24 | + :start => fill(NaN, nrows), |
| 25 | + :estimate => fill(NaN, nrows), |
| 26 | + :param => fill(Symbol(), nrows), |
| 27 | +) |
| 28 | + |
| 29 | +# construct using the provided columns data or create and empty table |
| 30 | +function ParameterTable( |
| 31 | + columns::Dict{Symbol, Vector} = empty_partable_columns(); |
18 | 32 | observed_vars::Union{AbstractVector{Symbol}, Nothing} = nothing, |
19 | 33 | latent_vars::Union{AbstractVector{Symbol}, Nothing} = nothing, |
20 | 34 | ) |
21 | | - columns = Dict{Symbol, Any}( |
22 | | - :from => Vector{Symbol}(), |
23 | | - :parameter_type => Vector{Symbol}(), |
24 | | - :to => Vector{Symbol}(), |
25 | | - :free => Vector{Bool}(), |
26 | | - :value_fixed => Vector{Float64}(), |
27 | | - :start => Vector{Float64}(), |
28 | | - :estimate => Vector{Float64}(), |
29 | | - :param => Vector{Symbol}(), |
30 | | - :start => Vector{Float64}(), |
31 | | - ) |
32 | | - |
33 | 35 | return ParameterTable(columns, |
34 | 36 | !isnothing(observed_vars) ? copy(observed_vars) : Vector{Symbol}(), |
35 | 37 | !isnothing(latent_vars) ? copy(latent_vars) : Vector{Symbol}(), |
|
0 commit comments