Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add convenience function to retrieve specific groups of factors #895

Open
ConnectedSystems opened this issue Oct 26, 2024 · 0 comments
Open

Comments

@ConnectedSystems
Copy link
Collaborator

ConnectedSystems commented Oct 26, 2024

It would be useful to retrieve parameter groups from the model spec.

Tentative implementation:

function extract_param_group_idx(model_spec::DataFrame, needle::String)::Vector{Int64}
    needle_pos = contains.(string.(model_spec.fieldname), needle)
    return findall(needle_pos)
end
function extract_param_group_idx(model::Model, component, needle::String)::Vector{Int64}
    comp_params = component_params(model, component)
    return extract_param_group_idx(comp_params, needle)
end

function extract_param_group(model::Model, component, needle::String)::DataFrame
    group_pos = extract_param_group_idx(model, component, needle)
    comp_params = component_params(model, component)
    return comp_params[group_pos, :]
end
function extract_param_group(model_spec::DataFrame, needle::String)::DataFrame
    group_pos = extract_param_group_idx(model_spec, needle)
    return model_spec[group_pos, :]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant