JuliaGaussianProcesses / JuliaGaussianProcesses/ParameterHandling.jl
Feature Request: `flatten_only`
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 74
- Forks
- 10
- PR merge metrics
- No merged PRs in 30d
Description
One of the biggest problems I have when handling parameters (whether I'm using ComponentArrays, Functors, ParameterHandling, etc.) is that I often only want to optimize (or do some other analysis) over a certain subset of the parameters. And, critically, that subset is going to be constantly changing. It would be nice to have a way to tag parameters for certain operations.
One way to accomplish this with ParameterHandling would be a flatten_only function that digs through the structure and only pulls out elements wrapped in a specified type. The idea is that a user would create a wrapper type and method for value that unwraps the object. I'm not 100% sure this is the best way to handle it (maybe it would be better for ParameterHandling to have a Tagged type that allows users to tag with symbols?), but here is an idea of what it would look like to use:
struct Tunable{T}
val::T
end
ParameterHandling.value(x::Tunable) = x.val
julia> raw_params = (
a = 1,
b = 2.5,
c = Tunable(3.1),
d = (
a = Tunable(4),
b = 5.1,
),
);
julia> tunable_params, unflatten = flatten_only(Tunable, raw_params);
julia> tunable_params
2-element Vector{Float64}:
3.1
4.0
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing ParameterHandling's existing flattening behavior and the value method described in the issue. Compare the proposed flatten_only example with the current parameter traversal, including nested structures. Done means extracting only wrapped values and returning an unflatten function that restores the original structure.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100