-
Notifications
You must be signed in to change notification settings - Fork 6
ParamsArray type #219
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
ParamsArray type #219
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## devel #219 +/- ##
==========================================
+ Coverage 71.69% 74.14% +2.44%
==========================================
Files 52 52
Lines 2120 2197 +77
==========================================
+ Hits 1520 1629 +109
+ Misses 600 568 -32 ☔ View full report in Codecov by Sentry. 🚨 Try these New Features:
|
a.param_ptr == b.param_ptr && | ||
a.linear_indices == b.linear_indices | ||
|
||
Base.hash(a::ParamsArray, h::UInt) = hash( |
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.
What do we need that for?
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.
I added ==
and hash()
so that ParamsArray
could be efficiently used as a key in AbstractDict
(particularly for matrices large dimensions).
The reason why I need it -- when I construct my regularized multi-group SEM, some terms might be duplicate and could therefore be merged, but it's hard to detect in advance (e.g. I may have series of replicate experiments that have either 100% identical design or each of the series may have some unique samples not present in the other series). So with Dict{ParamsArray, SEMTerm}()
I can automatically detect duplicate terms.
SEM.jl does not need/use it, so in principle I can move it to my code. But that's relatively little code, and by keeping it in SEM.jl
we avoid "type piracy".
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.
Alright, seems reasonable - let's keep it here then.
Thanks a lot, great PR - I just had some small comments, otherwise, i would merge it. |
no declarations, so import is not required
replaces RAMMatrices indices and constants vectors with dedicated class that incapsulate this logic, resulting in overall cleaner interface A_ind, S_ind, M_ind become ParamsArray F_ind becomes SparseMatrixCSC parameters.jl is not longer required and is removed
Thank you for the review! I've addressed your comments. |
5b9327e
into
StructuralEquationModels:devel
This PR is another subset of #193 changes and adds
ParamsArrays
type to simplify RAM specification.ParamsArray{T,N}
object defines N-dimensional array, whose elements are either constants of typeT
or parameters (specified as indices in parameters array).materialize(pararr, parvals)
,materialize!(arr, parrarr, parvals)
andsparse_materialize(pararr, parvals)
are used to create/update existing arrays with theparvals
parameter values according to thepararr::ParamsArray
specification.It also supports fast sparse gradients by the parameters vector via
sparse_gradient!()
.For lower level iteration over parameter references in an array, one can use the
param_occurences(pararr, i)
method that returns the linear indices of i-th param occurences.The PR switches
RAMMatrices
to use theParamsArray
for A and S matrices and M vector.