Skip to content

Commit

Permalink
fix quosures and add tests (#87)
Browse files Browse the repository at this point in the history
* fix quosures and add tests

* fix checkout action
  • Loading branch information
egillax authored Sep 8, 2023
1 parent e484060 commit 549e8a1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/R_CDM_check_hades.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 0 additions & 2 deletions R/Estimator.R
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down
23 changes: 15 additions & 8 deletions tests/testthat/test-Estimator.R
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down Expand Up @@ -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'))
#
# })
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))
})

0 comments on commit 549e8a1

Please sign in to comment.