Skip to content

Split r2f.R into domain-specific handler and helper files - #85

Merged
t-kalinowski merged 1 commit into
t-kalinowski:mainfrom
mns-nordicals:split-r2f.R
Jan 24, 2026
Merged

Split r2f.R into domain-specific handler and helper files#85
t-kalinowski merged 1 commit into
t-kalinowski:mainfrom
mns-nordicals:split-r2f.R

Conversation

@mns-nordicals

Copy link
Copy Markdown
Contributor

PR message

Refactor the monolithic R/r2f.R (~2000 lines) into 18 logically grouped files for better maintainability. No functional changes.

New structure:

  • r2f-aab-core.R: Core translation engine (renamed from r2f.R)
  • Handler files (14): arithmetic, logical, control-flow, reductions, subscript, sequences, conditionals, math, constructors, random, dimensions, io, coercions, core-handlers
  • Generic helper files (3): operators-helpers, iterables-helpers, reductions-helpers

Design principles:

  • Local helpers that are core handler logic that has been extracted stay with their handlers for readability
  • Generic helpers (used across domains) in dedicated helper files
  • Newspaper-style layout: handlers first, then local helpers where applicable

Extra comments

As discussed elsewhere, I (/ai) have tried to split the r2f file into smaller logical components. The extra lines should be white space and extra comments. Some files like random and coercion are very small, but I think there is room for more handler of these types. You are welcome to rename or combine files fi there are too many.

I actually thought there would be more "generic" helpers that can be reused over multiple files/handlers. I guess these are more common in the matrix files. However, I feel like there is potential to consolidate various helpers and create new ones for common patterns. There is probably also potential in refactoring tests at some point to better align with source code files.

Refactor the monolithic R/r2f.R (~2000 lines) into 18 logically
grouped files for better maintainability. No functional changes.

New structure:
- r2f-aab-core.R: Core translation engine (renamed from r2f.R)
- Handler files (14): arithmetic, logical, control-flow, reductions,
  subscript, sequences, conditionals, math, constructors, random,
  dimensions, io, coercions, core-handlers
- Helper files (3): operators-helpers, iterables-helpers,
  reductions-helpers

Design principles:
- Local helpers stay with their handlers for readability
- Generic helpers (used across domains) in dedicated helper files
- Newspaper-style layout: handlers first, then local helpers where applicable
@codecov

codecov Bot commented Jan 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.32353% with 59 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.42%. Comparing base (7df1780) to head (b9d4068).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
R/r2f-aab-core.R 83.26% 43 Missing ⚠️
R/r2f-math.R 0.00% 8 Missing ⚠️
R/r2f-reductions-helpers.R 81.48% 5 Missing ⚠️
R/r2f-operators-helpers.R 96.80% 3 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main      #85   +/-   ##
=======================================
  Coverage   92.42%   92.42%           
=======================================
  Files          22       26    +4     
  Lines        4606     4606           
=======================================
  Hits         4257     4257           
  Misses        349      349           

☔ 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.

@t-kalinowski

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 👍

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@t-kalinowski

Copy link
Copy Markdown
Owner

FYI, the benchmark results where we compare quickr to RcppArmadillo seemed suspect to me, so I've started a local branch investigating, and I'll be pushing out some updates to the LA code soon (with an updated benchmark that is more in line with what I expect).

@t-kalinowski
t-kalinowski merged commit f6654f4 into t-kalinowski:main Jan 24, 2026
11 of 13 checks passed
@t-kalinowski

Copy link
Copy Markdown
Owner

Thank you!

@mns-nordicals
mns-nordicals deleted the split-r2f.R branch July 3, 2026 17:38
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.

2 participants