From ee09f83dd312d456ad19de36895b0e486828b10d Mon Sep 17 00:00:00 2001 From: egillax Date: Mon, 10 Oct 2022 11:32:43 +0200 Subject: [PATCH] add tests for if random sample is higher than possible combinations --- tests/testthat/test-MLP.R | 17 +++++++++++++++++ tests/testthat/test-ResNet.R | 17 +++++++++++++++++ tests/testthat/test-Transformer.R | 6 ++++++ 3 files changed, 40 insertions(+) diff --git a/tests/testthat/test-MLP.R b/tests/testthat/test-MLP.R index 3bc0d8f..97d7103 100644 --- a/tests/testthat/test-MLP.R +++ b/tests/testthat/test-MLP.R @@ -108,3 +108,20 @@ test_that("MLP nn-module works ", { # model works without numeric variables expect_equal(output$shape, 10) }) + + +test_that("Errors are produced by settings function", { + randomSample <- 2 + + expect_error(setMultiLayerPerceptron( + numLayers = 1, + sizeHidden = 128, + dropout = 0.0, + sizeEmbedding = 128, + weightDecay = 1e-6, + learningRate = 0.01, + seed = 42, + hyperParamSearch = 'random', + randomSample = randomSample)) + +}) \ No newline at end of file diff --git a/tests/testthat/test-ResNet.R b/tests/testthat/test-ResNet.R index 626d39d..8f5a12f 100644 --- a/tests/testthat/test-ResNet.R +++ b/tests/testthat/test-ResNet.R @@ -124,3 +124,20 @@ test_that("Default Resnet works", { expect_equal(params$sizeEmbedding, 256) }) + +test_that("Errors are produced by settings function", { + randomSample <- 2 + + expect_error(setResNet( + numLayers = 1, + sizeHidden = 128, + hiddenFactor = 1, + residualDropout = 0.0, + hiddenDropout = 0.0, + sizeEmbedding = 128, + weightDecay = 1e-6, + learningRate = 0.01, + seed = 42, + hyperParamSearch = 'random', + randomSample = randomSample)) +}) diff --git a/tests/testthat/test-Transformer.R b/tests/testthat/test-Transformer.R index b8e1e22..228e881 100644 --- a/tests/testthat/test-Transformer.R +++ b/tests/testthat/test-Transformer.R @@ -74,3 +74,9 @@ test_that("Default Transformer works", { expect_equal(settings$name, 'defaultTransformer') }) + +test_that("Errors are produced by settings function", { + randomSample <- 2 + + expect_error(setTransformer(randomSample = randomSample)) +})