You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ParameterHandling.jl is a nice framework for organising parameters into nested NamedTuples. Whilst working with them in JuliaGaussianProcesses/AbstractGPs.jl#240, what I was missing is a nice way of printing this parameter structure. It seems like the best place to sort this out is within ParameterHandling directly, as it needs to know about the various constraints to print them properly.
So far, I've got the following stub:
using Printf
functionshow_params(nt::NamedTuple, pre=0)
res =""for (s, v) inpairs(nt)
iftypeof(v) <:NamedTuple
res *=join(fill("", pre)) *"$(s):\n"*show_params(v, pre+4)
else
res *=join(fill("", pre)) *"$s = $(@sprintf("%.3f", v))\n"endendreturn res
end
which then gets called as print(show_params(ParameterHandling.value(param_struct))).
Ideally, I would like to avoid the call to value to remove all the constraints, and instead add the corresponding information (e.g. scale = 1.345 (positive)).
And of course would have to think a bit harder to make it work well for vectors/matrices etc... so I thought it better to first start a discussion about what might be reasonable:)
Update: Oh, and of course instead of directly printing, it should implement show so it works well both in REPL and notebooks.
The text was updated successfully, but these errors were encountered:
julia> params_template = (
k1 = (
a =fixed(0.9),
b =positive(1.0),
),
k2 = (
a =bounded(0.15, 0.1, 0.2),
b =-3.0,
),
c =22.0,
)
julia> params_template
(k1 = (a =0.9 [fixed], b =1.0∈ ℝ+), k2 = (a =0.15∈ [0.1, 0.2], b =-3.0), c =22.0)
We would need to think a bit more carefully how to print the types in a meaningful way.
Maybe print them as we type them? E.g. bounded(0.15,0.1, 0.2) would be printed simply as bounded(0.15, 0.1, 0.2)?
ParameterHandling.jl is a nice framework for organising parameters into nested NamedTuples. Whilst working with them in JuliaGaussianProcesses/AbstractGPs.jl#240, what I was missing is a nice way of printing this parameter structure. It seems like the best place to sort this out is within ParameterHandling directly, as it needs to know about the various constraints to print them properly.
So far, I've got the following stub:
which then gets called as
print(show_params(ParameterHandling.value(param_struct)))
.Ideally, I would like to avoid the call to
value
to remove all the constraints, and instead add the corresponding information (e.g.scale = 1.345 (positive)
).And of course would have to think a bit harder to make it work well for vectors/matrices etc... so I thought it better to first start a discussion about what might be reasonable:)
Update: Oh, and of course instead of directly printing, it should implement
show
so it works well both in REPL and notebooks.The text was updated successfully, but these errors were encountered: