Skip to content

Refactor analysis functions to utilize cheapr for efficiency#134

Merged
mattcieslak merged 5 commits intomainfrom
enh/incorporate-cheapr
Apr 28, 2026
Merged

Refactor analysis functions to utilize cheapr for efficiency#134
mattcieslak merged 5 commits intomainfrom
enh/incorporate-cheapr

Conversation

@araikes
Copy link
Copy Markdown
Collaborator

@araikes araikes commented Apr 24, 2026

Minimizing memory footprint and redundant object copies speeds up processing. This PR introduces functions from the cheapr package to accomplish this. Comparisons against the 0.1.5 release (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.
profiling_overview_panel

Closes #133

araikes added 5 commits April 23, 2026 13:08
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-commenter
Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.73684% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.53%. Comparing base (f833f90) to head (ca73ef9).

Files with missing lines Patch % Lines
R/ModelArray_Constructor.R 75.00% 2 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@araikes araikes requested a review from mattcieslak April 27, 2026 17:19
Copy link
Copy Markdown
Contributor

@mattcieslak mattcieslak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

@mattcieslak mattcieslak merged commit 556abf1 into main Apr 28, 2026
4 checks passed
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.

Use cheapr functions for lower memory

3 participants