Skip to content

Commit

Permalink
Drop internal update_version
Browse files Browse the repository at this point in the history
  • Loading branch information
seananderson committed May 26, 2024
1 parent 75a6700 commit c78771b
Showing 1 changed file with 0 additions and 46 deletions.
46 changes: 0 additions & 46 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -611,52 +611,6 @@ get_fitted_time <- function(x) {
x$fitted_time
}

update_version <- function(object) {
if (object$version < "0.4.3") {
cli::cli_abort("`update_version()` only works with models fit with version 0.4.3 or later.")
}
if (!"fitted_time" %in% names(object)) { # < 0.4.3.9004
object$fitted_time <- sort(unique(object$data[[object$time]]))

et <- object$extra_time
o <- object$tmb_obj$env$data$offset_i
real_data_n <- length(o) - length(et)
o <- o[seq(1, real_data_n)]
object$offset <- o

y <- object$response
y <- y[seq(1, real_data_n), , drop = FALSE]
object$response <- y

d <- object$data
d[["__fake_data__"]] <- d[["__weight_sdmTMB__"]] <-
d[["__sdmTMB_offset__"]] <- d[["__dcens_upr__"]] <- NULL
d <- d[seq(1, real_data_n), , drop = FALSE]
object$data <- d
}

# add gengamma_Q
p <- object$tmb_obj$env$parList()
if (!"gengamma_Q" %in% names(p)) {
p$gengamma_Q <- 1 # not defined at 0
ee <- object$tmb_obj$env
map <- object$tmb_map
map$gengamma_Q <- factor(NA)
object$tmb_obj <- TMB::MakeADFun(
data = ee$data,
parameters = p,
map = map,
random = ee$random,
silent = ee$silent,
DLL = "sdmTMB"
)
object$tmb_obj$fn(object$model$par)
object$tmb_obj$env$last.par.best <- ee$last.par.best
object$tmb_map <- map
}
object
}

reload_model <- function(object) {
if ("parlist" %in% names(object)) {
# tinyVAST does this to be extra sure... I've found one case where it was needed
Expand Down

0 comments on commit c78771b

Please sign in to comment.