tests/testthat/helpers.R

# This script is run automatically when testthat::test_dir(testthat::test_path()) is called.

compileTestModels <- function(testData, testModelTypes, priors = NULL, userEstimates = NULL) {
  testResultsVec <- list()
  
  # new column added: values[["optimalPrior"]], default value == TRUE
  testData$optimalPrior <- TRUE
  
  for (i in 1:length(testModelTypes)) {
    typeName <- names(testModelTypes)[i]
    
    # set specific modelType
    testData$modelType <- testModelTypes[i]
    
    print(paste("Compiling modelType:", typeName))
    startTime <- Sys.time()
    testResultsVec[[typeName]] <-
      try({
        compileRunModel(
          fruitsObj = shinyInputToClass(testData,
                                        priors = as.list(priors),
                                        userEstimates = as.list(userEstimates)),
          progress = FALSE,
          userDefinedAlphas = testData$userDefinedAlphas
        )
      },
      silent = TRUE)
    
    print(difftime(Sys.time(), startTime))
  }
  
  testResultsVec
}
Pandora-IsoMemo/resources documentation built on Nov. 21, 2024, 3:56 a.m.