mrc-ide/deterministic-malaria-model

Do not use odin() within a package

Closed this issue · 0 comments

The point of having the odin code within the package is that it's good to use from the moment the package is installed - there's no need to call odin::odin() to create the generator because you already have a copy good to use.

So instead of doing (model_functions.R)

  odin_model_path <- system.file("extdata/odin_model.R",package="ICDMM")
  gen <- odin::odin(odin_model_path,verbose=FALSE)

you would use

  gen <- odin_model

Similarly, in generator_utils.R but there it's more complex so you might do:

gen <- switch(
  odin_model = odin_model,
  odin_model_parity_GOOD_drugs_newP = odin_model_parity_GOOD_drugs_newP,
  stop(sprintf("Unknown model '%s'", odin_model)))

If you need that function to also be extendable to code outside the package it can be supported but should not be needed generally.