Skip to content

Commit 8c7cd14

Browse files
Maximilian-Stefan-Ernstalyst
authored andcommitted
ParTable: add graph-based kw-only constructor
1 parent 673aa2b commit 8c7cd14

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/frontend/specification/ParameterTable.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ empty_partable_columns(nrows::Integer = 0) = Dict{Symbol, Vector}(
2727
:param => fill(Symbol(), nrows),
2828
)
2929

30-
# construct using the provided columns data or create and empty table
30+
# construct using the provided columns data or create an empty table
3131
function ParameterTable(
32-
columns::Dict{Symbol, Vector} = empty_partable_columns();
32+
columns::Dict{Symbol, Vector};
3333
observed_vars::Union{AbstractVector{Symbol}, Nothing} = nothing,
3434
latent_vars::Union{AbstractVector{Symbol}, Nothing} = nothing,
3535
params::Union{AbstractVector{Symbol}, Nothing} = nothing,

src/frontend/specification/StenoGraphs.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,17 @@ function ParameterTable(
129129
return ParameterTable(columns; latent_vars, observed_vars, params)
130130
end
131131

132+
############################################################################################
133+
### keyword only constructor (for call in `Sem` constructor)
134+
############################################################################################
135+
136+
# FIXME: this kw-only ctor conflicts with the empty ParTable constructor;
137+
# it is left here for compatibility with the current Sem construction API,
138+
# the proper fix would be to move away from kw-only ctors in general
139+
ParameterTable(; graph::Union{AbstractStenoGraph, Nothing} = nothing, kwargs...) =
140+
!isnothing(graph) ? ParameterTable(graph; kwargs...) :
141+
ParameterTable(empty_partable_columns(); kwargs...)
142+
132143
############################################################################################
133144
### constructor for EnsembleParameterTable from graph
134145
############################################################################################

0 commit comments

Comments
 (0)