Refactor analysis functions to utilize cheapr for efficiency#134
Merged
mattcieslak merged 5 commits intomainfrom Apr 28, 2026
Merged
Refactor analysis functions to utilize cheapr for efficiency#134mattcieslak merged 5 commits intomainfrom
mattcieslak merged 5 commits intomainfrom
Conversation
Add cheapr (>= 1.5.0) to Imports and refactor analyse-helpers.R to use cheapr utilities. The validity mask is now accumulated into a single logical vector, indices are computed with cheapr::which_, and subsetting is done with cheapr::sset. Scalar columns are assembled via cheapr::fast_df and concatenated with cheapr::col_c instead of repeated logical indexing and Reduce, simplifying the code and improving efficiency.
Allow scalar to be inferred or passed.
Replace uses of rep(NaN, n) with cheapr::rep_len_(NaN, nL) and replace rbind+as.data.frame on result matrices with construction of column lists and cheapr::fast_df(.args = col_list). This improves performance, avoids unnecessary row-binding/coercion overhead, and ensures correct length typing. Changes touch R/ModelArray_Constructor.R (analyseOneElement.*) and R/analyse.R (ModelArray.lm, ModelArray.gam, ModelArray.wrap and reduced-model assembly).
Revert change so that tests pass.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #134 +/- ##
==========================================
+ Coverage 90.48% 90.53% +0.05%
==========================================
Files 6 6
Lines 1870 1881 +11
==========================================
+ Hits 1692 1703 +11
Misses 178 178 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Minimizing memory footprint and redundant object copies speeds up processing. This PR introduces functions from the

cheaprpackage to accomplish this. Comparisons against the0.1.5release (labeled as "current_release"), main branch 3 weeks ago after #126, modeling context (#131), and now that extended with cheapr are presented below benchmarked for a single core.Closes #133