RXR-2856 add input checks to get_map_estimates()#56
Merged
roninsightrx merged 5 commits intomasterfrom Sep 23, 2025
Merged
Conversation
mccarthy-m-g
requested changes
Sep 19, 2025
mccarthy-m-g
left a comment
There was a problem hiding this comment.
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)) { |
There was a problem hiding this comment.
Is this missing a !?
Suggested change
| if(any(names(parameters) %in% defined_parameters)) { | |
| if(any(!(names(parameters) %in% defined_parameters))) { |
There was a problem hiding this comment.
It might also be nice to identify which names are not supported so it's easy to correct them as a user
Contributor
Author
There was a problem hiding this comment.
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"), | ||
| ) |
There was a problem hiding this comment.
missing regex string for warning message
mccarthy-m-g
approved these changes
Sep 22, 2025
mccarthy-m-g
left a comment
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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"
)
})
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.