From 2c758a14ba2f535f630d9e4c25ea2b1a736e0b75 Mon Sep 17 00:00:00 2001 From: egillax Date: Fri, 8 Sep 2023 13:52:05 +0200 Subject: [PATCH 1/2] fix quosures and add tests --- R/Estimator.R | 2 -- tests/testthat/test-Estimator.R | 23 +++++++++++++++-------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/R/Estimator.R b/R/Estimator.R index 573c6a6..f804368 100644 --- a/R/Estimator.R +++ b/R/Estimator.R @@ -64,8 +64,6 @@ setEstimator <- function(learningRate='auto', checkHigher(batchSize, 0) checkIsClass(epochs, c("numeric", "integer")) checkHigher(epochs, 0) - checkIsClass(device, c("character", "function")) - checkIsClass(scheduler, "list") checkIsClass(earlyStopping, c("list", "NULL")) checkIsClass(metric, c("character", "list")) checkIsClass(seed, c("numeric", "integer", "NULL")) diff --git a/tests/testthat/test-Estimator.R b/tests/testthat/test-Estimator.R index b9ecadd..9cb1382 100644 --- a/tests/testthat/test-Estimator.R +++ b/tests/testthat/test-Estimator.R @@ -55,8 +55,6 @@ test_that("Estimator detects wrong inputs", { testthat::expect_error(setEstimator(batchSize = "text")) testthat::expect_error(setEstimator(epochs = 0)) testthat::expect_error(setEstimator(epochs = "test")) - testthat::expect_error(setEstimator(device = 1)) - testthat::expect_error(setEstimator(scheduler = "notList")) testthat::expect_error(setEstimator(earlyStopping = "notListorNull")) testthat::expect_error(setEstimator(metric = 1)) testthat::expect_error(setEstimator(seed = "32")) @@ -357,9 +355,18 @@ test_that("device as a function argument works", { }) -# test_that("estimatorSettings can be saved and loaded with correct objects", { -# settings <- setEstimator() -# -# saveRDS(settings,file=file.path(testLoc, 'settings.RDS')) -# -# }) \ No newline at end of file +test_that("estimatorSettings can be saved and loaded with correct python objects", { + settings <- setEstimator() + + saveRDS(settings,file=file.path(testLoc, 'settings.RDS')) + + loadedSettings <- readRDS(file = file.path(testLoc, 'settings.RDS')) + + optimizer <- loadedSettings$optimizer() + scheduler <- loadedSettings$scheduler() + criterion <- loadedSettings$criterion() + + testthat::expect_false(reticulate::py_is_null_xptr(optimizer)) + testthat::expect_false(reticulate::py_is_null_xptr(scheduler$fun)) + testthat::expect_false(reticulate::py_is_null_xptr(criterion)) +}) \ No newline at end of file From b5c16f364ab08ad9b96ed4aba83d58a1be5bfe5a Mon Sep 17 00:00:00 2001 From: egillax Date: Fri, 8 Sep 2023 14:06:52 +0200 Subject: [PATCH 2/2] fix checkout action --- .github/workflows/R_CDM_check_hades.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/R_CDM_check_hades.yaml b/.github/workflows/R_CDM_check_hades.yaml index fa5072b..a8e6186 100644 --- a/.github/workflows/R_CDM_check_hades.yaml +++ b/.github/workflows/R_CDM_check_hades.yaml @@ -45,7 +45,7 @@ jobs: CDM5_SQL_SERVER_USER: ${{ secrets.CDM5_SQL_SERVER_USER }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: r-lib/actions/setup-r@v2 with: