Skip to content

Commit

Permalink
Remove set_env_object_noinitial()
Browse files Browse the repository at this point in the history
  • Loading branch information
billdenney committed Mar 20, 2024
1 parent 83a437e commit 2c672f4
Showing 1 changed file with 0 additions and 27 deletions.
27 changes: 0 additions & 27 deletions R/tar_nlmixr.R
Original file line number Diff line number Diff line change
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

0 comments on commit 2c672f4

Please sign in to comment.