Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix quosures and add tests #87

Merged
merged 2 commits into from
Sep 8, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix quosures and add tests
  • Loading branch information
egillax committed Sep 8, 2023
commit 2c758a14ba2f535f630d9e4c25ea2b1a736e0b75
2 changes: 0 additions & 2 deletions R/Estimator.R
Original file line number Diff line number Diff line change
@@ -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"))
23 changes: 15 additions & 8 deletions tests/testthat/test-Estimator.R
Original file line number Diff line number Diff line change
@@ -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'))
#
# })
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))
})
Loading