Skip to content

Commit 998b04b

Browse files
simplify update_partable! syntax
1 parent e4b78b5 commit 998b04b

4 files changed

Lines changed: 23 additions & 12 deletions

File tree

docs/src/tutorials/constraints/constraints.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ As you can see, the optimizer converged (`:XTOL_REACHED`) and investigating the
162162
update_partable!(
163163
partable,
164164
:estimate_constr,
165-
param_labels(model_fit_constrained),
165+
model_fit_constrained,
166166
solution(model_fit_constrained),
167167
)
168168

docs/src/tutorials/inspection/inspection.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ We can also update the `ParameterTable` object with other information via [`upda
8787
se_bs = se_bootstrap(model_fit; n_boot = 20)
8888
se_he = se_hessian(model_fit)
8989
90-
update_partable!(partable, :se_hessian, param_labels(model_fit), se_he)
91-
update_partable!(partable, :se_bootstrap, param_labels(model_fit), se_bs)
90+
update_partable!(partable, :se_hessian, model_fit, se_he)
91+
update_partable!(partable, :se_bootstrap, model_fit, se_bs)
9292
9393
details(partable)
9494
```

docs/src/tutorials/regularization/regularization.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ sem_fit = fit(model)
129129
130130
update_estimate!(partable, sem_fit)
131131
132-
update_partable!(partable, :estimate_lasso, param_labels(fit_lasso), solution(fit_lasso))
132+
update_partable!(partable, :estimate_lasso, fit_lasso, solution(fit_lasso))
133133
134134
details(partable)
135135
```
@@ -167,7 +167,7 @@ fit_mixed = fit(model_mixed; engine = :Proximal, operator_g = prox_operator)
167167
Let's again compare the different results:
168168

169169
```@example reg
170-
update_partable!(partable, :estimate_mixed, param_labels(fit_mixed), solution(fit_mixed))
170+
update_partable!(partable, :estimate_mixed, fit_mixed, solution(fit_mixed))
171171
172172
details(partable)
173173
```

src/frontend/specification/ParameterTable.jl

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -288,14 +288,25 @@ function update_partable!(
288288
end
289289

290290
"""
291-
update_partable!(partable::AbstractParameterTable, param_labels::Vector{Symbol}, params, column)
292-
293-
Write parameter `values` into `column` of `partable`.
294-
295-
The `param_labels` and `params` vectors define the pairs of
296-
parameters, which are being matched to the `:param` column
297-
of the `partable`.
291+
(1) update_partable!(partable::AbstractParameterTable, column, fitted:SemFit, params, default = nothing)
292+
293+
(2) update_partable!(partable::AbstractParameterTable, column, param_labels::Vector{Symbol}, params, default = nothing)
294+
295+
Add a new column to a parameter table.
296+
`column` is the name of the column, `params` contains the values of the new column,
297+
and `fitted` or `param_labels` is used to match the values to the correct parameter labels.
298+
The `default` value is used if a parameter in `partable` does not occur in `param_labels`.
298299
"""
300+
function update_partable!(
301+
partable::AbstractParameterTable,
302+
column::Symbol,
303+
fitted::SemFit,
304+
params::AbstractVector,
305+
default::Any = nothing,
306+
)
307+
update_partable!(partable, column, param_labels(fitted), params, default)
308+
end
309+
299310
function update_partable!(
300311
partable::ParameterTable,
301312
column::Symbol,

0 commit comments

Comments
 (0)