nlmixr2 / rxode2

rxode2
https://nlmixr2.github.io/rxode2/
GNU General Public License v3.0
24 stars 6 forks source link

Feature request: Either make the error message clearer or switch to a warning with empty arguments in call to `rxRename()` #688

Closed billdenney closed 2 weeks ago

billdenney commented 1 month ago

I just spent an inordinate amount of time trying to find the error with my code where I had an extra comma in the call to rxRename, like below. I can take on the task of making the error message clearer or switching to a warning.

@mattfidler, would you prefer this to switch to a warning (something like "empty argument ignored") or keep as an error with a clearer message (something like "empty arguments not allowed")?

library(rxode2)
#> rxode2 2.1.2 using 8 threads (see ?getRxThreads)
#>   no cache: create with `rxCreateCache()`

mod1 <- function() {
  ini({
    # central 
    KA=2.94E-01
    CL=1.86E+01
    V2=4.02E+01
    # peripheral
    Q=1.05E+01
    V3=2.97E+02
    # effects
    Kin=1
    Kout=1
    EC50=200 
  })
  model({
    C2 <- centr/V2
    C3 <- peri/V3
    d/dt(depot) <- -KA*depot
    d/dt(centr) <- KA*depot - CL*C2 - Q*C2 + Q*C3
    d/dt(peri)  <- Q*C2 - Q*C3
    eff(0) <- 1
    d/dt(eff)   <- Kin - Kout*(1-C2/(EC50+C2))*eff
  })
}

rxRename(mod1, foo = eff, )
#> Error in FUN(X[[i]], ...): argument ".quoted" is missing, with no default

Created on 2024-06-11 with reprex v2.1.0

mattfidler commented 1 month ago

I think a warning is easier to deal with as a user. I lean in that direction. You can always turn warnings into errors with options.