Skip to content

names() and get() for a specific section should always return parameters in the same order #443

Closed
@bgctw

Description

@bgctw

I encountered the following behaviour in a complex Chains object inspected from Infiltrator prompt,
where names and get return variables in a different order (similar to #326):

infil> names(df.chn, :u0)                                                                                                                                                                    
11-element Vector{Symbol}:                                                                                                                                                                   
 :s₊α_R0                                                                                                                                                                                     
 :s₊R_N0                                                                                                                                                                                     
 :s₊I_P0                                                                                                                                                                                     
 :s₊R_P0                                                                                                                                                                                     
 :s₊L_P0                                                                                                                                                                                     
 :s₊α_P0                                                                                                                                                                                     
 :s₊L0                                                                                                                                                                                       
 :s₊L_N0                                                                                                                                                                                     
 :s₊I_N0                                                                                                                                                                                     
 :s₊R0                                                                                                                                                                                       
 :s₊B0                                                                                                                                                                                       
                                                                                                                                                                                                                                                                                                                                                                                       
infil> keys(get(df.chn, section=:u0))                                                                                                                                                                                                                                                                                                                                                   
(:s₊R_N0, :s₊R_P0, :s₊L_N0, :s₊I_N0, :s₊L0, :s₊α_R0, :s₊B0, :s₊L_P0, :s₊α_P0, :s₊R0, :s₊I_P0)   

I failed to construct a MWE. The following works as expected:

ulia> chn1 = Chains(rand(100, 4, 2), [:a, :b, :c, :d]);

julia> chn1s = set_section(chn1, Dict(:parameters => [:a,:b], :u0 => [:d, :c]));

julia> names(chn1s, :u0)
2-element Vector{Symbol}:
 :d
 :c

julia> keys(get(chn1s, section = :u0))
(:d, :c)

Encountered on Julia 1.9.2 and MCMCChains v6.0.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions