Skip to content
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

Code review #25

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ Description:
'nlmixr2targets' ensures minimal rework in model development with 'nlmixr2'
and 'targets' by simplifying and standardizing models and datasets.
License: GPL (>= 2)
Depends:
R (>= 4.1)
Imports:
checkmate,
digest,
nlmixr2est,
rxode2 (>= 2.0.14),
targets
Suggests:
covr,
knitr,
Expand All @@ -20,11 +28,5 @@ Encoding: UTF-8
LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.1
Imports:
checkmate,
digest,
nlmixr2est,
rxode2 (>= 2.0.14),
targets
URL: https://nlmixr2.github.io/nlmixr2targets/
VignetteBuilder: knitr
4 changes: 2 additions & 2 deletions R/simplify.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#' `cmt(initial)` will be converted to `cmt(0)` before passing to nlmixr2.
#'
#' @inheritParams nlmixr2est::nlmixr
#' @return \code{object} converted to a nlmixrui object. The model name is
#' @returns \code{object} converted to a nlmixrui object. The model name is
#' always "object".
#' @family Simplifiers
#' @export
Expand Down Expand Up @@ -65,7 +65,7 @@ nlmixr_object_simplify_zero_initial_helper <- function(object) {
#' @inheritParams nlmixr2est::nlmixr
#' @param object an nlmixr_ui object (e.g. the output of running
#' \code{nlmixr(object = model)}
#' @return The data with the nlmixr2 column lower case and on the left and the
#' @returns The data with the nlmixr2 column lower case and on the left and the
#' covariate columns on the right and alphabetically sorted.
#' @family Simplifiers
#' @export
Expand Down
29 changes: 1 addition & 28 deletions R/tar_nlmixr.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#' @inheritParams targets::tar_target
#' @param env The environment where the model is setup (not needed for typical
#' use)
#' @return A list of targets for the model simplification, data simplification,
#' @returns A list of targets for the model simplification, data simplification,
#' and model estimation.
#' @examples
#' \dontrun{
Expand Down Expand Up @@ -79,8 +79,6 @@ tar_nlmixr_raw <- function(name, object, data, est, control, table, object_simpl
checkmate::assert_character(object_simple_name, len = 1, min.chars = 1, any.missing = FALSE)
checkmate::assert_character(data_simple_name, len = 1, min.chars = 1, any.missing = FALSE)

# Make models with initial conditions set work within `targets` (see #15)
set_env_object_noinitial(object = object, env = env)
list(
object_simple =
targets::tar_target_raw(
Expand Down Expand Up @@ -143,31 +141,6 @@ tar_nlmixr_raw <- function(name, object, data, est, control, table, object_simpl
)
}

#' Ensure that an object is set in its initial environment so that it is
#' protected from the `targets` domain-specific-language issue of
#' `pd(0) <- initial`
#'
#' @inheritParams tar_nlmixr
#' @return NULL (called for side effects)
#' @noRd
set_env_object_noinitial <- function(object, env) {
if (is.name(object)) {
object_env <- env[[as.character(object)]]
if (is.function(object_env)) {
object_result <- try(rxode2::assertRxUi(object_env), silent = TRUE)
if (inherits(object_result, "rxUi")) {
assign(x = as.character(object), value = object_result, envir = env)
}
}
} else if (is.call(object)) {
# Recursively iterate over all parts of the call
lapply(X = object, FUN = set_env_object_noinitial, env = env)
}
# If it's anything other than a name or a call, then we don't need to modify
# it or its sub-objects.
NULL
}

#' Replace the fit data with the original data, then return the modified fit
#'
#' This function is intended for use within `nlmixr2targets` target creation,
Expand Down
2 changes: 1 addition & 1 deletion R/tar_nlmixr_multimodel.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#' @inheritParams nlmixr2est::nlmixr
#' @inheritParams targets::tar_target
#' @inheritParams tar_nlmixr
#' @return A list of targets for the model simplification, data simplification,
#' @returns A list of targets for the model simplification, data simplification,
#' and model estimation.
#' @export
tar_nlmixr_multimodel <- function(name, ..., data, est, control = list(), table = nlmixr2est::tableControl(), env = parent.frame()) {
Expand Down
10 changes: 10 additions & 0 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
## R CMD check results

0 errors | 0 warnings | 1 note

* Even simple workflows for the `nlmixr2targets` library take significant
runtime, more than the few seconds allowed for examples. And, typical
workflows also have a significant amount of code associated with them (tens to
hundreds of lines). For these reasons, the individual functions do not have
running examples and user-focused examples are put into the vignette.
* This is a new release.
Loading