Skip to content
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

Cleanup Variables API #207

Merged
merged 26 commits into from
Jul 31, 2024

Conversation

alyst
Copy link
Contributor

@alyst alyst commented Jun 17, 2024

Another round of cherry-picks from #193 that cleans up the variables API, as discussed in #199:

  • vars()/nvars() methods to get the vector of SEM model variables/count of variables.
  • observed_vars()/nobserved_vars() to get the vector of observed variables ordered as in observed data (nobserved_vars() replaces n_man() method)
  • latent_vars()/nlatent_vars() to get the vector of latent variables, preserving their order in vars()
  • get_data() renamed to samples(), nsamples() is the number of data points/samples/observations in the observed data (nsamples() replaces n_obs() method)
  • for SemMissingData nmeasured_vars() is the count of observed variables with measurements (within the given data pattern)
  • interface method definitions are moved from types.jl to the files, where the methods of a particular type are defined (new files are created to accommodate methods for the abstract classes, e.g. SemSpecification)
  • these variable API methods should work not only for the SEM specification objects, like RAMMatrices or ParameterTable, but also for the types that refer to SEM specification (SemImply, AbstractSem etc)
  • old methods using ambiguous terms get_colnames(), or get_n_nodes() removed

Per #199 discussion, an alternative to observed/latent terms would be manifest/latent. Also, samples could be replaced with observations (keeping both nobserved_vars() and nobservations() may lead to confusion), and measured/missing terms could be replaced with observed/missing. I really don't have a strong preference here, so if SEM stakeholders think manifest/latent + observed/missing is a better choice, I can update the PR.
Also, I think obs_cov/obs_mean have to be updated accordingly (observed_cov/observed_mean or manifest_cov/manifest_mean).

This PR should be really the last one that does not introduce improvements or new features, but it should help to make the improvements easier.

src/frontend/fit/summary.jl Outdated Show resolved Hide resolved
src/imply/RAM/generic.jl Show resolved Hide resolved
Copy link

codecov bot commented Jun 17, 2024

Codecov Report

Attention: Patch coverage is 91.27907% with 15 lines in your changes missing coverage. Please review.

Project coverage is 70.52%. Comparing base (b2012b0) to head (2f6e8b7).
Report is 1 commits behind head on devel.

Files Patch % Lines
src/frontend/specification/RAMMatrices.jl 71.42% 4 Missing ⚠️
src/observed/EM.jl 80.00% 4 Missing ⚠️
src/frontend/specification/StenoGraphs.jl 80.00% 2 Missing ⚠️
src/frontend/common.jl 80.00% 1 Missing ⚠️
src/frontend/fit/standard_errors/bootstrap.jl 0.00% 1 Missing ⚠️
src/frontend/fit/summary.jl 0.00% 1 Missing ⚠️
src/imply/RAM/generic.jl 93.33% 1 Missing ⚠️
src/imply/RAM/symbolic.jl 85.71% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##            devel     #207      +/-   ##
==========================================
+ Coverage   69.64%   70.52%   +0.88%     
==========================================
  Files          51       52       +1     
  Lines        2421     2446      +25     
==========================================
+ Hits         1686     1725      +39     
+ Misses        735      721      -14     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@alyst
Copy link
Contributor Author

alyst commented Jun 27, 2024

@Maximilian-Stefan-Ernst I have also cleaned up the existing unit tests and added the tests to cover the vars/params API calls

@Maximilian-Stefan-Ernst
Copy link
Collaborator

Thanks again for this great PR, and also for adding/restructuring tests. Sorry for taking so long to review. If the comments are resolved, this is ready to merge; I also agree with the terminology.

@alyst
Copy link
Contributor Author

alyst commented Jul 30, 2024

@Maximilian-Stefan-Ernst Thank you for the review. I think I've addressed your comments: params, vars and observed APIs are now exported, StenoGraph explicit dependency is removed from the tests, as well as the alternative check_acyclic() method.
Params suggestions look like false positives (again). I wonder if the new v3 version of julia-format action fixes that.

@Maximilian-Stefan-Ernst Maximilian-Stefan-Ernst merged commit 399845f into StructuralEquationModels:devel Jul 31, 2024
4 of 5 checks passed
@Maximilian-Stefan-Ernst
Copy link
Collaborator

Thanks, I will update julia-format...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants