Skip to content

Comments

Add forceEncode option for regex-based option encoding#68

Merged
vandenman merged 6 commits intojasp-stats:masterfrom
FBartos:fix-model-syntax
Jan 30, 2026
Merged

Add forceEncode option for regex-based option encoding#68
vandenman merged 6 commits intojasp-stats:masterfrom
FBartos:fix-model-syntax

Conversation

@FBartos
Copy link
Contributor

@FBartos FBartos commented Jan 30, 2026

Introduces a forceEncode argument to encodeOptionsAndDataset and related functions, allowing specified option names (e.g., 'model') to have column names replaced via word-boundary-aware regex. Updates documentation and test cases to cover this feature, ensuring only specified options are affected and partial matches are avoided.

AND

Added logic to re-encode the 'model' field from 'modelOriginal' when both are present in options, ensuring consistent encoding with our scheme rather than JASP's. Updated tests to verify correct re-encoding and preservation of the original modelOriginal field.

Introduces a forceEncode argument to encodeOptionsAndDataset and related functions, allowing specified option names (e.g., 'model') to have column names replaced via word-boundary-aware regex. Updates documentation and test cases to cover this feature, ensuring only specified options are affected and partial matches are avoided.
Copilot AI review requested due to automatic review settings January 30, 2026 09:05
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces a forceEncode parameter to the encoding workflow, enabling regex-based variable name replacement in options that contain embedded column names (like formula strings) but lack corresponding .types metadata. The feature is implemented across the encoding, test generation, and documentation layers.

Changes:

  • Adds forceEncode parameter to encodeOptionsAndDataset() and related functions to enable regex-based column name replacement using word-boundary-aware patterns
  • Implements forceEncodeValue() helper function that uses negative lookahead/lookbehind regex to replace variable names while avoiding partial matches
  • Updates test generator functions to propagate forceEncode through the call chain and include it in generated test code
  • Adds comprehensive test cases covering basic usage, multiple options, word boundary handling, and selective application

Reviewed changes

Copilot reviewed 9 out of 10 changed files in this pull request and generated 3 comments.

File Description
R/dataset.R Adds forceEncode parameter to encodeOptionsAndDataset() and encodeOptionsWithMap(), implements forceEncodeValue() with regex-based replacement logic
R/test-generator.R Propagates forceEncode through makeTestsFromExamples(), makeTestsFromSingleJASPFile(), and test block generators, updates generated test code to include forceEncode when specified
tests/testthat/test-encodeOptionsAndDataset.R Adds four test cases covering basic regex encoding, selective option encoding, multiple options, and word boundary handling
man/*.Rd Updates documentation for all modified functions to document the new forceEncode parameter

Updated the flattenRecursive function in fixOptionsForVariableTypes to preserve user-facing fields (such as 'model' and 'modelOriginal') alongside the flattened value, while excluding internal JASP metadata fields. This ensures that relevant user data is not lost during the flattening process.
Added logic to re-encode the 'model' field from 'modelOriginal' when both are present in options, ensuring consistent encoding with our scheme rather than JASP's. Updated tests to verify correct re-encoding and preservation of the original modelOriginal field.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 10 out of 11 changed files in this pull request and generated 3 comments.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@FBartos FBartos requested a review from vandenman January 30, 2026 10:44
@vandenman vandenman merged commit 3928759 into jasp-stats:master Jan 30, 2026
9 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.

2 participants