Skip to content

fix(fit): accept a PM_result or data frame as prior - #397

Open
mhovd wants to merge 1 commit into
mainfrom
claude/pmetrics-pmcore-pharmsol-fixes-qdno6d-prior-result
Open

mhovd wants to merge 1 commit into
mainfrom
claude/pmetrics-pmcore-pharmsol-fixes-qdno6d-prior-result

Conversation

@mhovd

@mhovd mhovd commented Oct 11, 2026

Copy link
Copy Markdown
Collaborator

Bug. A length(prior) == 1 guard sent every data-frame or PM_result prior back to a Sobol grid, with no message. As a result, PM_result$continue() restarted from scratch.

Fix.

  • A PM_result prior uses its $final$popPoints.
  • A data frame is used as given.
  • Any other value is now an error instead of a silent fallback to Sobol.

Tests. Mocked fits cover a PM_result prior, a data-frame prior and an unsupported prior.

Note. This changes PM_model$fit, so test-data-currency.R will fail until data/*.rda is regenerated.

🤖 Generated with Claude Code

https://claude.ai/code/session_01GTyUgJEd5uCEmv9qYrv8dC


Generated by Claude Code

A length(prior) == 1 guard sent every data frame or PM_result prior back
to a Sobol grid without a message, so PM_result$continue() restarted
from scratch. A PM_result now uses its final support points, a data frame
is used as is, and any other value is an error.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GTyUgJEd5uCEmv9qYrv8dC
Copilot AI balanced review requested due to automatic review settings October 11, 2026 10:13

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The new PM_result test errors in the earlier Sobol guard before exercising the changed behavior.

1 open finding
What changed in this PR

Updates prior handling so fits can reuse support points instead of silently falling back to Sobol.

Changes:

  • Accepts PM_result and data-frame priors.
  • Rejects unsupported prior values.
  • Adds mocked prior-handling tests.
File Description
R/​PM_model.R Expands prior validation and conversion.
tests/​testthat/​test-pm-fit-prior-parameters.R Tests object priors and rejection behavior.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +196 to +198
params <- tolower(names(NPex$model$model_list$pri))
prior_df <- make_prior_df(params)
prior_result <- structure(list(final = list(popPoints = prior_df)), class = "PM_result")
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 66.66667% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 64.88%. Comparing base (ef474a1) to head (258af7f).

Files with missing lines Patch % Lines
R/PM_model.R 66.66% 4 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #397      +/-   ##
==========================================
+ Coverage   64.77%   64.88%   +0.10%     
==========================================
  Files          52       52              
  Lines       22964    22984      +20     
==========================================
+ Hits        14876    14914      +38     
+ Misses       8088     8070      -18     
Files with missing lines Coverage Δ
R/PM_model.R 67.86% <66.66%> (+0.46%) ⬆️

... and 14 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

This branch has not been deployed

No deployments
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.

4 participants