-
Notifications
You must be signed in to change notification settings - Fork 6
No-op code & docs cleanups #245
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: devel
Are you sure you want to change the base?
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## devel #245 +/- ##
==========================================
- Coverage 72.94% 72.24% -0.71%
==========================================
Files 50 51 +1
Lines 2218 2212 -6
==========================================
- Hits 1618 1598 -20
- Misses 600 614 +14 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
I've rebased the PR after the #253 got merged. @Maximilian-Stefan-Ernst I have also noticed that you have implemented #246. So I have added commits that revert #246 in this PR, but also updated the optimization documentation to be in sync with the actual opt. engine API:
Please let me know if you have any concerns regarding these changes, I will be happy to address them. |
|
@Maximilian-Stefan-Ernst @brandmaier @aaronpeikert In the recent months the merging of some of the changes from my staging branch (PR #193) into the main branch was dormant. But I would be still interested in it, if you think it will be beneficial for the SEM.jl. I mention it, because I see there are new issues/PRs, which could at least partially be addressed in PR #193. Thank you! |
|
The FormatCheck action updates were extracted to PR #296. |
|
Thanks a lot! I merged #296 - is this PR ready for review, or is there anything else you would like to add before? |
also remove unused _symbolic fields
This reverts commit 9729819.
This reverts commit 81a4bd9.
This reverts commit f0df653.
It is a simple and intuitive syntax and avoids declaring new types. Also allow specifying default constraint tolerance as `constraint_tol`.
use SemOptimizer(engine = :NLopt) instead of SemOptimizerNLopt() as this is a more universal scheme
|
@Maximilian-Stefan-Ernst Thank you! I've just rebased this branch to the latest devel, but somehow GitHub does not pick up the |
|
Alright, I'll review - I will also try to remind myself why I made the changes related to package extensions and write something about it. W.r.t. the FormatCheck action - I believe changes to workflows only take effect once they are merged into main - I added the changes to main now, so it should pick up. |
|
Okay, w.r.t. the package extensions: I believe the problem was that there was no way to access types defined in extensions at the time. This seems to be fixed now, but it is still cumbersome (https://discourse.julialang.org/t/having-trouble-using-types-defined-in-extension-modules/97260): using StructuralEquationModels, NLopt
?SemOptimizerNLopt
Couldn't find SemOptimizerNLopt
Perhaps you meant SemOptimizerEmpty
No documentation found.
Binding SemOptimizerNLopt does not exist.
m = Base.get_extension(StructuralEquationModels, :SEMNLOptExt)
?m.SemOptimizerNLoptSo out of the box, this leads to some problems - without explicitely using So I thought the main objective of having extensions is to avoid unnecessary dependencies - therefore I moved the types that are defined to the main package, so they are accessible, and their definition does not depend on the dependencies. Definitions of new methods, however, remained in the extension because they actually depend on additonal packages. However, I really like your changes to the documentation, and the improved syntax for defining constraints, and I would definitely keep those. I am also happy with reverting the changes and moving the types back to the extension, the only thing we would need to fix is the accessibility of the documentation. I also pushed these changes to another branch because I did not manage to manually trigger the documentation build workflow on this PR, but it is now here (https://github.com/StructuralEquationModels/StructuralEquationModels.jl/actions/runs/21357427498/job/61468060053) and it also seems to have the issue of accessing the documentation of types defined in extensions. So the only thing I can think of atm would be to move the documentation of all extensions to |
Yes, initially, I had the same confusion about Julia extensions.
I totally agree, the extensions need to provide the docstrings for the specific engine parameters, but currently in this PR it does not happen as it documents Which kind of use case you have in mind for allowing the users to define methods on the types of extensions?
+1 for fixing the docs.
Yes, I agree -- it might be too long and unspecific. I'll take a look how this is handled in other packages. To improve the discovery, I can also try adding the function |
| inequality_constraints = nothing, | ||
| constraint_tol::Number = 0.0, | ||
| kwargs...) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
| !isa(inequality_constraints, NamedTuple) || |
|
|
||
| # computes A*S*B -> C, where ind gives the entries of S that are 1 | ||
| function sparse_outer_mul!(C, A, B, ind) | ||
| function sparse_outer_mul!(C, A, B, ind) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
| function sparse_outer_mul!(C, A, B, ind) | |
| function sparse_outer_mul!(C, A, B, ind) |
|
|
||
| # computes A*∇m, where ∇m ind gives the entries of ∇m that are 1 | ||
| function sparse_outer_mul!(C, A, ind) | ||
| function sparse_outer_mul!(C, A, ind) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
| function sparse_outer_mul!(C, A, ind) | |
| function sparse_outer_mul!(C, A, ind) |
|
|
||
| # computes A*S*B -> C, where ind gives the entries of S that are 1 | ||
| function sparse_outer_mul!(C, A, B::Vector, ind) | ||
| function sparse_outer_mul!(C, A, B::Vector, ind) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
| function sparse_outer_mul!(C, A, B::Vector, ind) | |
| function sparse_outer_mul!(C, A, B::Vector, ind) |
| ArgumentError( | ||
| "StructuralEquationModels does not support the `CoefTable` interface; see [`ParameterTable`](@ref) instead.", | ||
| ), | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
| ) | |
| coeftable(model::AbstractSem; level::Real = 0.95) = throw( | |
| ArgumentError( | |
| "StructuralEquationModels does not support the `CoefTable` interface; see [`ParameterTable`](@ref) instead.", | |
| ), | |
| ) | |
| StructuralEquationModels.minimum(fit_prox) - StructuralEquationModels.minimum(sem_fit), | ||
| StructuralEquationModels.minimum(fit_prox) - | ||
| StructuralEquationModels.minimum(sem_fit), | ||
| ) < 1.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
| ) < 1.0 | |
| StructuralEquationModels.minimum(fit_prox) - | |
| StructuralEquationModels.minimum(sem_fit), |
| model = Sem(specification = partable, data = data) | ||
| model_fit = fit(model) | ||
|
|
||
| @testset "params" begin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
| model = Sem(specification = partable, data = data) | |
| model_fit = fit(model) | |
| @testset "params" begin | |
| model = Sem(specification = partable, data = data) |
| end | ||
|
|
||
|
|
||
| ram_matrices = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
| ram_matrices = |
| "specification" => "SemSpecification", | ||
| "model" => "Sem model", | ||
| "StatsAPI" => "StatsAPI" | ||
| "StatsAPI" => "StatsAPI", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
| "StatsAPI" => "StatsAPI", | |
| "StatsAPI" => "StatsAPI", |
| @warn "Error initializing Test Env" exception=(e, catch_backtrace()) | ||
| end | ||
| include("unit_tests.jl") | ||
| include("unit_tests.jl") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
| include("unit_tests.jl") | |
| include("unit_tests.jl") | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
StructuralEquationModels.jl/src/additional_functions/params_array.jl
Lines 202 to 206 in acd1748
| function sparse_materialize(::Type{T}, arr::ParamsMatrix, params::AbstractVector) where {T} | |
| nparams(arr) == length(params) || throw( | |
| DimensionMismatch( | |
| "Number of values ($(length(params))) does not match the number of parameter ($(nparams(arr)))", | |
| ), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
StructuralEquationModels.jl/src/additional_functions/params_array.jl
Lines 254 to 255 in acd1748
| for i in first_i:last_i | |
| if isempty(param_occurences_range(arr, i)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
StructuralEquationModels.jl/src/frontend/StatsAPI.jl
Lines 16 to 20 in acd1748
| function params!(out::AbstractVector, partable::ParameterTable, col::Symbol = :estimate) | |
| (length(out) == nparams(partable)) || throw( | |
| DimensionMismatch( | |
| "The length of parameter values vector ($(length(out))) does not match the number of parameters ($(nparams(partable)))", | |
| ), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶
StructuralEquationModels.jl/test/examples/helper.jl
Lines 93 to 98 in acd1748
| expected = | |
| StructuralEquationModels.lavaan_params(partable_lav, partable, lav_col, lav_group) | |
| @test !any(isnan, actual) | |
| @test !any(isnan, expected) | |
| if skip # workaround skip=false not supported in earlier versions |
These are rather trivial commits cherry-picked from #193 that don't change anything essential, but once they are in, it should be easier to manage the rest.
The changes are:
usingdirectives from the individual unit test .jl files to the parent .jl fileRAMSymbolicrenamexxx_functiontoxxx_eval!as that better follows Julia naming conventions and should make the code a bit more readable (and shorter)This is a bit less trivial set of changes than the rest, but in the end it does not really change how the functions are calculated.
Except for switching p-values calculation to use
ccdf(x)instead of1 - cdf(x)-- this could potentially give more precise results for p-values close to 0.