Skip to content

Commit 9592edc

Browse files
committed
move Sem methods out of types.jl
1 parent 772157b commit 9592edc

2 files changed

Lines changed: 33 additions & 38 deletions

File tree

src/frontend/specification/Sem.jl

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,42 @@ latent_vars(sem::AbstractSemSingle) = latent_vars(sem.imply)
3030

3131
nsamples(sem::AbstractSemSingle) = nsamples(sem.observed)
3232

33+
params(model::AbstractSem) = params(model.imply)
34+
3335
# sum of samples in all sub-models
3436
nsamples(ensemble::SemEnsemble) = sum(nsamples, ensemble.sems)
3537

38+
############################################################################################
39+
# additional methods
40+
############################################################################################
41+
"""
42+
observed(model::AbstractSemSingle) -> SemObserved
43+
44+
Returns the observed part of a model.
45+
"""
46+
observed(model::AbstractSemSingle) = model.observed
47+
48+
"""
49+
imply(model::AbstractSemSingle) -> SemImply
50+
51+
Returns the imply part of a model.
52+
"""
53+
imply(model::AbstractSemSingle) = model.imply
54+
55+
"""
56+
loss(model::AbstractSemSingle) -> SemLoss
57+
58+
Returns the loss part of a model.
59+
"""
60+
loss(model::AbstractSemSingle) = model.loss
61+
62+
"""
63+
optimizer(model::AbstractSemSingle) -> SemOptimizer
64+
65+
Returns the optimizer part of a model.
66+
"""
67+
optimizer(model::AbstractSemSingle) = model.optimizer
68+
3669
function SemFiniteDiff(;
3770
observed::O = SemObservedData,
3871
imply::I = RAM,

src/types.jl

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,6 @@ abstract type AbstractSemCollection <: AbstractSem end
1313
"Supertype for all loss functions of SEMs. If you want to implement a custom loss function, it should be a subtype of `SemLossFunction`."
1414
abstract type SemLossFunction end
1515

16-
"""
17-
params(semobj)
18-
19-
Return the vector of SEM model parameters.
20-
"""
21-
params(model::AbstractSem) = model.params
22-
2316
"""
2417
SemLoss(args...; loss_weights = nothing, ...)
2518
@@ -225,37 +218,6 @@ Returns the optimizer part of an ensemble model.
225218
"""
226219
optimizer(ensemble::SemEnsemble) = ensemble.optimizer
227220

228-
############################################################################################
229-
# additional methods
230-
############################################################################################
231-
"""
232-
observed(model::AbstractSemSingle) -> SemObserved
233-
234-
Returns the observed part of a model.
235-
"""
236-
observed(model::AbstractSemSingle) = model.observed
237-
238-
"""
239-
imply(model::AbstractSemSingle) -> SemImply
240-
241-
Returns the imply part of a model.
242-
"""
243-
imply(model::AbstractSemSingle) = model.imply
244-
245-
"""
246-
loss(model::AbstractSemSingle) -> SemLoss
247-
248-
Returns the loss part of a model.
249-
"""
250-
loss(model::AbstractSemSingle) = model.loss
251-
252-
"""
253-
optimizer(model::AbstractSemSingle) -> SemOptimizer
254-
255-
Returns the optimizer part of a model.
256-
"""
257-
optimizer(model::AbstractSemSingle) = model.optimizer
258-
259221
"""
260222
Base type for all SEM specifications.
261223
"""

0 commit comments

Comments
 (0)