tests/testthat/test.secondModelTry.R

context("evaluateModel")

test_that("test evaluate model", {
    set.seed(1)

    lower = c(-2, -3)
    upper = c(1, 2)

    modelFun <- function(x , y, control){
        res <- buildKriging(x, y, control)
        class(res) <- "failureModel"
        return(res)
    }

    failureCount <- 1
    predict.failureModel <<- function(object, newdata, ...){
        failureCount <<- failureCount + 1
        if(failureCount > 5){
            failureCount <<- 1
        }
        if(failureCount == 5){
            stop("simulated error in predicting")
        }
        return(predict.kriging(object, newdata, ...))
    }
    expect_message(
    res <- spot(x = NULL, fun = funSphere,
         lower = lower, upper = upper,
         control = list(
             model = modelFun,
             verbosity = 0
         )))
})

Try the SPOT package in your browser

Any scripts or data that you put into this service are public.

SPOT documentation built on June 26, 2022, 1:06 a.m.