Skip to content

Commit a569d0e

Browse files
Alexey Stukalovalyst
authored andcommitted
n_par() -> nparams()
for clarity and aligning to Julia naming conventions
1 parent 1f835a0 commit a569d0e

20 files changed

Lines changed: 36 additions & 38 deletions

File tree

docs/src/developer/imply.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ To make stored computations available to loss functions, simply write a function
3030

3131
Additionally, you can specify methods for `gradient` and `hessian` as well as the combinations described in [Custom loss functions](@ref).
3232

33-
The last thing nedded to make it work is a method for `n_par` that takes your imply type and returns the number of parameters of the model:
33+
The last thing nedded to make it work is a method for `nparams` that takes your imply type and returns the number of parameters of the model:
3434

3535
```julia
36-
n_par(imply::MyImply) = ...
36+
nparams(imply::MyImply) = ...
3737
```
3838

3939
Just as described in [Custom loss functions](@ref), you may define a constructor. Typically, this will depend on the `specification = ...` argument that can be a `ParameterTable` or a `RAMMatrices` object.

src/StructuralEquationModels.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,14 +150,14 @@ export AbstractSem,
150150
sort_vars,
151151
RAMMatrices,
152152
params,
153+
nparams,
153154
fit_measures,
154155
AIC,
155156
BIC,
156157
χ²,
157158
df,
158159
fit_measures,
159160
minus2ll,
160-
n_par,
161161
n_obs,
162162
p_value,
163163
RMSEA,

src/additional_functions/simulation.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ function swap_observed(
7373
# update imply
7474
imply = update_observed(imply, new_observed; kwargs...)
7575
kwargs[:imply] = imply
76-
kwargs[:n_par] = n_par(imply)
76+
kwargs[:nparams] = nparams(imply)
7777

7878
# update loss
7979
loss = update_observed(loss, new_observed; kwargs...)

src/frontend/fit/SemFit.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ end
4747
############################################################################################
4848

4949
params(fit::SemFit) = params(fit.model)
50-
n_par(fit::SemFit) = n_par(fit.model)
50+
nparams(fit::SemFit) = nparams(fit.model)
5151

5252
# access fields
5353
minimum(sem_fit::SemFit) = sem_fit.minimum

src/frontend/fit/fitmeasures/AIC.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
44
Return the akaike information criterion.
55
"""
6-
AIC(sem_fit::SemFit) = minus2ll(sem_fit) + 2n_par(sem_fit)
6+
AIC(sem_fit::SemFit) = minus2ll(sem_fit) + 2nparams(sem_fit)

src/frontend/fit/fitmeasures/BIC.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
44
Return the bayesian information criterion.
55
"""
6-
BIC(sem_fit::SemFit) = minus2ll(sem_fit) + log(n_obs(sem_fit)) * n_par(sem_fit)
6+
BIC(sem_fit::SemFit) = minus2ll(sem_fit) + log(n_obs(sem_fit)) * nparams(sem_fit)

src/frontend/fit/fitmeasures/df.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ function df end
88

99
df(sem_fit::SemFit) = df(sem_fit.model)
1010

11-
df(model::AbstractSem) = n_dp(model) - n_par(model)
11+
df(model::AbstractSem) = n_dp(model) - nparams(model)
1212

1313
function n_dp(model::AbstractSemSingle)
1414
nman = n_man(model)

src/frontend/fit/fitmeasures/fit_measures.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
fit_measures(sem_fit) =
2-
fit_measures(sem_fit, n_par, df, AIC, BIC, RMSEA, χ², p_value, minus2ll)
2+
fit_measures(sem_fit, nparams, df, AIC, BIC, RMSEA, χ², p_value, minus2ll)
33

44
function fit_measures(sem_fit, args...)
55
measures = Dict{Symbol, Union{Float64, Missing}}()

src/frontend/fit/summary.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function sem_summary(
1616
println("Convergence: $(convergence(sem_fit))")
1717
println("No. iterations/evaluations: $(n_iterations(sem_fit))")
1818
print("\n")
19-
println("Number of parameters: $(n_par(sem_fit))")
19+
println("Number of parameters: $(nparams(sem_fit))")
2020
println("Number of observations: $(n_obs(sem_fit))")
2121
print("\n")
2222
printstyled(

src/frontend/specification/ParameterTable.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ Base.iterate(partable::ParameterTable, i::Integer) =
143143
i > length(partable) ? nothing : (partable[i], i + 1)
144144

145145
params(partable::ParameterTable) = partable.params
146-
n_par(partable::ParameterTable) = length(params(partable))
146+
nparams(partable::ParameterTable) = length(params(partable))
147147

148148
# Sorting ----------------------------------------------------------------------------------
149149

0 commit comments

Comments
 (0)