File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -265,3 +265,30 @@ function params_range(arr::ParamsArray; allow_gaps::Bool = false)
265265
266266 return first_i: last_i
267267end
268+
269+ """
270+ filter_used_params([linearindex_test], arr::ParamsArray)
271+
272+ Filter the parameters that are referenced in the `arr`, and
273+ the linear indices of the corresponding parameters pass the
274+ optional `linearindex_test`.
275+
276+ Returns the indices of the used parameters.
277+ """
278+ function filter_used_params (linearindex_test, arr:: ParamsArray )
279+ inds = Vector {Int} ()
280+ for i in 1 : nparams (arr)
281+ par_range = SEM. param_occurences_range (arr, i)
282+ isempty (par_range) && continue # not relevant
283+ @inbounds for j in par_range
284+ lin_ind = arr. linear_indices[j]
285+ if isnothing (linearindex_test) || linearindex_test (lin_ind)
286+ push! (inds, i)
287+ break
288+ end
289+ end
290+ end
291+ return inds
292+ end
293+
294+ filter_used_params (arr:: ParamsArray ) = filter_used_params (nothing , arr)
You can’t perform that action at this time.
0 commit comments