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
function show_params(nt::NamedTuple, pre=0)
res = ""
for (s, v) in pairs(nt)
if typeof(v) <: NamedTuple
res *= join(fill(" ", pre)) * "$(s):\n" * show_params(v, pre+4)
else
res *= join(fill(" ", pre)) * "$s = $(@sprintf("%.3f", v))\n"
end
end
return 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.
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
valueto 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
showso it works well both in REPL and notebooks.