From 18367a393227abc5da30816a8dee9b20f9573a82 Mon Sep 17 00:00:00 2001 From: hbaniecki Date: Thu, 7 May 2020 00:07:25 +0200 Subject: [PATCH] fix tests --- tests/testthat/test_ms_update_observations.R | 26 +++++++++++--------- tests/testthat/test_warnings_and_errors.R | 16 ++++++------ 2 files changed, 23 insertions(+), 19 deletions(-) diff --git a/tests/testthat/test_ms_update_observations.R b/tests/testthat/test_ms_update_observations.R index fbba0f8..1a30912 100644 --- a/tests/testthat/test_ms_update_observations.R +++ b/tests/testthat/test_ms_update_observations.R @@ -2,26 +2,30 @@ context("Check ms_update_observations() function") source("test_objects.R") -ms <- modelStudio::modelStudio(explain_rf, apartments[1:2,], N = 5, B = 2) +ms <- modelStudio::modelStudio(explain_rf, apartments[1:2,], N = 5, B = 2, show_info = v) testthat::test_that("modelStudio class", { testthat::expect_is(ms, "modelStudio") testthat::expect_silent(ms) }) -new_ms1 <- modelStudio::ms_update_options(ms, explain_rf, B = 3) -new_ms2 <- modelStudio::ms_update_options(ms, explain_rf, - new_observation = apartments[100:101,], - B = 3, overwrite = FALSE) -new_ms3 <- modelStudio::ms_update_options(ms, explain_rf, - new_observation = apartments[1:2,], - B = 3, overwrite = TRUE) +new_ms1 <- modelStudio::ms_update_observations(ms, explain_rf, B = 2, show_info = v) +new_ms2 <- modelStudio::ms_update_observations(ms, explain_rf, B = 2, show_info = v, + new_observation = apartments[100:101,], + overwrite = FALSE) +new_ms3 <- modelStudio::ms_update_observations(ms, explain_rf, B = 2, show_info = v, + new_observation = apartments[1:2,], + overwrite = TRUE) testthat::test_that("ms_update_observations", { testthat::expect_is(new_ms1, "modelStudio") - testthat::expect_silent(new_ms1) + testthat::expect_silent(modelStudio::ms_update_observations(ms, explain_rf, B = 2, show_info = v)) testthat::expect_is(new_ms2, "modelStudio") - testthat::expect_silent(new_ms2) + testthat::expect_silent(modelStudio::ms_update_observations(ms, explain_rf, B = 2, show_info = v, + new_observation = apartments[100:101,], + overwrite = FALSE)) testthat::expect_is(new_ms3, "modelStudio") - testthat::expect_silent(new_ms3) + testthat::expect_silent(modelStudio::ms_update_observations(ms, explain_rf, B = 2, show_info = v, + new_observation = apartments[1:2,], + overwrite = TRUE)) }) diff --git a/tests/testthat/test_warnings_and_errors.R b/tests/testthat/test_warnings_and_errors.R index 6b69792..f103997 100644 --- a/tests/testthat/test_warnings_and_errors.R +++ b/tests/testthat/test_warnings_and_errors.R @@ -6,7 +6,7 @@ testthat::test_that("new_observation as list", { testthat::expect_warning( modelStudio::modelStudio(explain_glm, new_observation = as.list(titanic_test[1,-9]), - show_info = v) + show_info = v, B = 3) ) }) @@ -14,7 +14,7 @@ testthat::test_that("check_single_prediction error", { testthat::expect_error( modelStudio::modelStudio(explainer_xgb, new_observation = model_matrix_train[1,], - show_info = v) + show_info = v, B = 3) ) }) @@ -25,15 +25,15 @@ testthat::test_that("deprecated modelStudioOptions", { }) ms <- modelStudio::modelStudio(explain_rf, apartments[1:2,], N = 5, B = 2, show_info = v) -new_ms <- modelStudio::ms_update_options(ms, explain_rf, B = 2, show_info = v, - new_observation = apartments[1,], - new_observation_y = apartments$m2.price[1]) +new_ms <- modelStudio::ms_update_observations(ms, explain_rf, B = 2, show_info = v, + new_observation = apartments[1,], + new_observation_y = apartments$m2.price[1]) testthat::test_that("duplicated ids", { testthat::expect_is(new_ms, "modelStudio") testthat::expect_warning( - modelStudio::ms_update_options(ms, explain_rf, B = 2, show_info = v, - new_observation = apartments[1,], - new_observation_y = apartments$m2.price[1]) + modelStudio::ms_update_observations(ms, explain_rf, B = 2, show_info = v, + new_observation = apartments[1,], + new_observation_y = apartments$m2.price[1]) ) })