Skip to content

Simplify read-only model identifiers - #23

Merged
wjakethompson merged 9 commits into
r-dcm:mainfrom
t-kalinowski:fix/s7-compatibility-preview-20261012
Oct 19, 2026
Merged

wjakethompson merged 9 commits into
r-dcm:mainfrom
t-kalinowski:fix/s7-compatibility-preview-20261012

Conversation

@t-kalinowski

Copy link
Copy Markdown
Contributor

Use a getter-only property for inherited model identifiers so generated S7 constructors use the parent’s initialization and validation. Name model_args in lcdm(), loglinear(), hdcm(), and bayesnet() so those arguments still reach the right property with the generated constructors.

After construction, model identifiers reject every assignment, including assignment of the existing value, with S7’s read-only property error. Add public constructor and validation regressions for all twelve model types.

@codecov

codecov Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 87.50000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 94.75%. Comparing base (3b4b5de) to head (69e6a74).

Files with missing lines Patch % Lines
R/zzz-class-model-components.R 87.50% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #23      +/-   ##
==========================================
+ Coverage   94.64%   94.75%   +0.11%     
==========================================
  Files          22       22              
  Lines        2689     2689              
==========================================
+ Hits         2545     2548       +3     
+ Misses        144      141       -3     

☔ View full report in Codecov by Harness.
📢 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.

@wjakethompson
wjakethompson merged commit 6cbaff5 into r-dcm:main Oct 19, 2026
9 of 11 checks passed
@t-kalinowski

Copy link
Copy Markdown
Contributor Author

Thanks for merging these changes! I'm planning to submit the next version of S7 to CRAN on November 16 (see RConsortium/S7#786).

Would you be able to submit an updated version of dcmstan with these compatibility updates to CRAN before then? Please let me know if you need more time or if there’s anything I can help with.

@wjakethompson

Copy link
Copy Markdown
Contributor

@t-kalinowski I would be happy to! One question: Currently I have set everything up for the new S7. For example, I updated zzz.R to use functions that are only available in the next version.

dcmstan/R/zzz.R

Lines 1 to 9 in 6cbaff5

.onLoad <- function(...) {
S7::S7_on_load()
}
.onUnload <- function(...) {
S7::S7_on_unload()
}
S7::S7_on_build()

Do you have any guidance/resources on how to be compatible with both versions of S7?

@t-kalinowski

Copy link
Copy Markdown
Contributor Author

Thanks, Jake. For the hooks, you can check for the new exports and keep methods_register() as the fallback for older S7:

.onLoad <- function(...) {
  if ("S7_on_load" %in% getNamespaceExports("S7")) {
    getExportedValue("S7", "S7_on_load")()
  } else {
    S7::methods_register()
  }
}

.onUnload <- function(...) {
  if ("S7_on_unload" %in% getNamespaceExports("S7")) {
    getExportedValue("S7", "S7_on_unload")()
  }
}

if ("S7_on_build" %in% getNamespaceExports("S7")) {
  getExportedValue("S7", "S7_on_build")()
}

Keep the build hook at the top level, after all method declarations. Using getExportedValue() also avoids check warnings about functions that aren't exported by older S7. This handles the hooks; other uses of new S7 features would need to be checked separately.

We're planning to submit S7 1.0.0 today, so keeping the new hooks, requiring S7 (>= 1.0.0), and submitting dcmstan once S7 is on CRAN would also be fine.

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