-
Notifications
You must be signed in to change notification settings - Fork 0
RXR-2856 add input checks to get_map_estimates() #56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
mccarthy-m-g
left a comment
There was a problem hiding this 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)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this missing a !?
| if(any(names(parameters) %in% defined_parameters)) { | |
| if(any(!(names(parameters) %in% defined_parameters))) { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
| check_inputs(model, data, parameters, omega, regimen, NULL, "MAP"), | ||
| ) |
There was a problem hiding this comment.
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
mccarthy-m-g
left a comment
There was a problem hiding this 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:
| 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.
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"
)
})
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.