Skip to content

Commit

Permalink
Fix symengine compiled user functions
Browse files Browse the repository at this point in the history
  • Loading branch information
mattfidler committed Nov 1, 2023
1 parent 116db18 commit 0b4436f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion R/symengine.R
Original file line number Diff line number Diff line change
Expand Up @@ -2247,7 +2247,7 @@ rxS <- function(x, doConst = TRUE, promoteLinSens = FALSE, envir=parent.frame())
.env$rx_hi_ <- symengine::S("1")
if (!is.null(rxode2parse::.rxSEeqUsr())) {
sapply(names(rxode2parse::.rxSEeqUsr()), function(x) {
assign(.rxFunction(x), x, envir = .env)
assign(x, .rxFunction(x), envir = .env)
})
}
## EulerGamma=0.57721566490153286060651209008240243104215933593992
Expand Down
12 changes: 10 additions & 2 deletions tests/testthat/test-udf.R
Original file line number Diff line number Diff line change
Expand Up @@ -295,11 +295,19 @@ rxTest({
test_that("symengine load", {

mod <- "tke=THETA[1];\nprop.sd=THETA[2];\neta.ke=ETA[1];\nke=gg(tke,exp(eta.ke));\nipre=gg(10,exp(-ke*t));\nlipre=log(ipre);\nrx_yj_~2;\nrx_lambda_~1;\nrx_low_~0;\nrx_hi_~1;\nrx_pred_f_~ipre;\nrx_pred_~rx_pred_f_;\nrx_r_~(rx_pred_f_*prop.sd)^2;\n"

gg <- function(x, y) {
PreciseSums::psProd(c(x, y))
x * y
}

rxS(mod, TRUE, TRUE)
expect_error(rxS(mod, TRUE, TRUE), NA)

rxFun(gg)

rm(gg)

expect_error(rxS(mod, TRUE, TRUE), NA)


})
})

0 comments on commit 0b4436f

Please sign in to comment.