Skip to content

Conversation

@roninsightrx
Copy link
Contributor

@roninsightrx roninsightrx commented Sep 19, 2025

I don't think these changes should have an effect on production code. Where the error is implemented now, it would've failed before as well, just not as elegantly. The warning may occur in production code, but that should not have an effect.
I'll run the functional tests anyhow.

Copy link

@mccarthy-m-g mccarthy-m-g left a comment

Choose a reason for hiding this comment

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

Just a few things to address first:

R/check_inputs.R Outdated
if(! all(defined_parameters %in% names(parameters))) {
stop("One or more required parameters for the model have not been specified.")
}
if(any(names(parameters) %in% defined_parameters)) {

Choose a reason for hiding this comment

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

Is this missing a !?

Suggested change
if(any(names(parameters) %in% defined_parameters)) {
if(any(!(names(parameters) %in% defined_parameters))) {

Choose a reason for hiding this comment

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

It might also be nice to identify which names are not supported so it's easy to correct them as a user

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, ! dropped out by accident. Will make it more verbose

Comment on lines 238 to 239
check_inputs(model, data, parameters, omega, regimen, NULL, "MAP"),
)

Choose a reason for hiding this comment

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

missing regex string for warning message

Copy link

@mccarthy-m-g mccarthy-m-g left a comment

Choose a reason for hiding this comment

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

lgtm! Maybe just add one more test before merging:

Comment on lines +22 to +24
if(is.null(defined_parameters)) {
warning("Parameter information for model missing, cannot perform parameter consistency check. Please check PKPDsim model definition.")
} else {

Choose a reason for hiding this comment

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

Could you please add a test for this condition?

test_that("check_inputs warns when no parameters are defined as model attribute", {
  model <- function() {}
  data <- data.frame(time = 1:3, dv = c(1, 2, 3))
  parameters <- list(CL = 1) # , V = 10)
  omega <- matrix(c(0.1, 0, 0, 0.1), nrow = 2)
  regimen <- list(dose = 100, interval = 12)
  expect_warning(
    check_inputs(model, data, parameters, omega, regimen, NULL, "MAP"),
    "Parameter information for model missing"
  )
})

@roninsightrx roninsightrx merged commit e7437a7 into master Sep 23, 2025
1 check passed
@roninsightrx roninsightrx deleted the RXR-2856-input-checks branch September 23, 2025 16:44
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.

3 participants