Skip to content

Commit

Permalink
Wrap in try-error and the load if there is an issue
Browse files Browse the repository at this point in the history
  • Loading branch information
mattfidler committed Oct 23, 2024
1 parent 906b503 commit 0aa83c5
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions R/poped.R
Original file line number Diff line number Diff line change
Expand Up @@ -342,13 +342,23 @@ rxUiGet.popedFfFun <- function(x, ...) {
.p <- babelmixr2::popedMultipleEndpointParam(p, .u, model_switch,
.(.poped$maxn),
poped.db$babelmixr2$optTime)
.ret <- .popedSolveIdME(.p, .u, .xt, model_switch, .(length(.predDf$cond)),
.id-1, .totn)
.ret <- try(.popedSolveIdME(.p, .u, .xt, model_switch, .(length(.predDf$cond)),
.id-1, .totn), silent=TRUE)
if (inherits(.ret, "try-error")) {
rxode2::rxLoad(poped.db$babelmixr2$modelMT)
.ret <- .popedSolveIdME(.p, .u, .xt, model_switch, .(length(.predDf$cond)),
.id-1, .totn)
}
} else if (.lu > .(.poped$maxn)) {
.p <- p[-1]
poped.db <- .popedRxRunFullSetupMe(poped.db, .xt, model_switch)
.ret <- .popedSolveIdME2(.p, .u, .xt, model_switch, .(length(.predDf$cond)),
.id-1, .totn)
.ret <- try(.popedSolveIdME2(.p, .u, .xt, model_switch, .(length(.predDf$cond)),
.id-1, .totn), silent=TRUE)
if (inherits(.ret, "try-error")) {
rxode2::rxLoad(poped.db$babelmixr2$modelF)
.ret <- .popedSolveIdME2(.p, .u, .xt, model_switch, .(length(.predDf$cond)),
.id-1, .totn)
}
}
return(list(f=matrix(.ret$rx_pred_, ncol=1),
poped.db=poped.db))
Expand Down Expand Up @@ -1981,7 +1991,6 @@ rxUiGet.popedOptsw <- function(x, ...) {
.setupPopEDdatabase <- function(ui, data, control) {
# PopED environment needs:
# - control - popedControl

#
# Data needs to match what PopED prefers, so order by id, dvid then time, not the typical ordering. This only needs to be done in cases where there is a dvid.
#
Expand Down Expand Up @@ -2931,8 +2940,6 @@ rxUiDeparse.popedControl <- function(object, var) {
nlmixr2est::.deparseFinal(.default, object, .w, var)
}



.popedFamilyControl <- function(env, ...) {
.ui <- env$ui
.control <- env$control
Expand Down

0 comments on commit 0aa83c5

Please sign in to comment.