From 22b9b095669fb1a6732b22000fa3aea4616adf1b Mon Sep 17 00:00:00 2001 From: Tim Cadman <41470917+timcadman@users.noreply.github.com> Date: Thu, 16 Apr 2026 13:14:31 +0200 Subject: [PATCH 1/4] refactor: batch-8 server-side RNG and sampling functions --- R/rBinomDS.R | 6 ++---- R/rNormDS.R | 6 ++---- R/rPoisDS.R | 3 +-- R/rUnifDS.R | 6 ++---- R/sampleDS.R | 4 ++-- R/setSeedDS.R | 6 +++++- tests/testthat/test-smk-rBinomDS.R | 10 ++++++++++ tests/testthat/test-smk-rNormDS.R | 10 ++++++++++ tests/testthat/test-smk-rPoisDS.R | 6 ++++++ tests/testthat/test-smk-rUnifDS.R | 10 ++++++++++ tests/testthat/test-smk-sampleDS.R | 10 ++++++++++ tests/testthat/test-smk-setSeedDS.R | 10 ++++++++++ 12 files changed, 70 insertions(+), 17 deletions(-) diff --git a/R/rBinomDS.R b/R/rBinomDS.R index 22bcbbf3..bc60cf50 100644 --- a/R/rBinomDS.R +++ b/R/rBinomDS.R @@ -34,13 +34,11 @@ rBinomDS<-function (n, size = 1, prob = 0.5){ #first convert their names into the corresponding active vectors if(is.character(size)){ - command.text<-size - size<-eval(parse(text=command.text), envir = parent.frame()) + size<-.loadServersideObject(size) } if(is.character(prob)){ - command.text<-prob - prob<-eval(parse(text=command.text), envir = parent.frame()) + prob<-.loadServersideObject(prob) } stats::rbinom(n, size=size, prob=prob) diff --git a/R/rNormDS.R b/R/rNormDS.R index f50a424e..9184cb24 100644 --- a/R/rNormDS.R +++ b/R/rNormDS.R @@ -39,13 +39,11 @@ rNormDS<-function (n, mean = 0, sd = 1, force.output.to.k.decimal.places=9){ #first convert their names into the corresponding active vectors if(is.character(mean)){ - command.text<-mean - mean<-eval(parse(text=command.text), envir = parent.frame()) + mean<-.loadServersideObject(mean) } if(is.character(sd)){ - command.text<-sd - sd<-eval(parse(text=command.text), envir = parent.frame()) + sd<-.loadServersideObject(sd) } random.number.vector<-stats::rnorm(n, mean=mean, sd=sd) diff --git a/R/rPoisDS.R b/R/rPoisDS.R index 3274078c..9c42292c 100644 --- a/R/rPoisDS.R +++ b/R/rPoisDS.R @@ -30,8 +30,7 @@ rPoisDS<-function (n, lambda = 1){ #first convert its name into the corresponding active vectors if(is.character(lambda)){ - command.text<-lambda - lambda<-eval(parse(text=command.text), envir = parent.frame()) + lambda<-.loadServersideObject(lambda) } stats::rpois(n, lambda=lambda) diff --git a/R/rUnifDS.R b/R/rUnifDS.R index 9f4463c6..5ca52c55 100644 --- a/R/rUnifDS.R +++ b/R/rUnifDS.R @@ -39,13 +39,11 @@ rUnifDS<-function (n, min = 0, max = 1, force.output.to.k.decimal.places=9){ #first convert their names into the corresponding active vectors if(is.character(min)){ - command.text<-min - min<-eval(parse(text=command.text), envir = parent.frame()) + min<-.loadServersideObject(min) } if(is.character(max)){ - command.text<-max - max<-eval(parse(text=command.text), envir = parent.frame()) + max<-.loadServersideObject(max) } random.number.vector<-stats::runif(n, min=min, max=max) diff --git a/R/sampleDS.R b/R/sampleDS.R index 1c5bd43f..ef068916 100644 --- a/R/sampleDS.R +++ b/R/sampleDS.R @@ -82,7 +82,7 @@ sampleDS <- function(x.transmit, size.transmit, replace.transmit=NULL, prob.tran #Activate and if they are character strings if(is.character(x.transmit)) { - x.active<-eval(parse(text=x.transmit), envir = parent.frame()) + x.active<-.loadServersideObject(x.transmit) if(is.data.frame(x.active)||is.matrix(x.active)) { @@ -152,7 +152,7 @@ sampleDS <- function(x.transmit, size.transmit, replace.transmit=NULL, prob.tran prob.active<-NULL if(is.character(prob.transmit)) { - prob.active<-eval(parse(text=prob.transmit), envir = parent.frame()) + prob.active<-.loadServersideObject(prob.transmit) } #Check size <= length(x.active) if replace.transmit==FALSE diff --git a/R/setSeedDS.R b/R/setSeedDS.R index 6515d51a..75dbace3 100644 --- a/R/setSeedDS.R +++ b/R/setSeedDS.R @@ -38,7 +38,11 @@ setSeedDS<-function (seedtext=NULL, kind = NULL, normal.kind = NULL) # Check Permissive Privacy Control Level. dsBase::checkPermissivePrivacyControlLevel(c('permissive', 'avocado')) - seed<-eval(parse(text=seedtext), envir = parent.frame()) + if(is.null(seedtext) || seedtext == "NULL"){ + seed <- NULL + } else { + seed <- as.integer(seedtext) + } set.seed(seed,kind,normal.kind) return(list(seed.as.set=.Random.seed)) } diff --git a/tests/testthat/test-smk-rBinomDS.R b/tests/testthat/test-smk-rBinomDS.R index 9cff07d0..a25d1a5b 100644 --- a/tests/testthat/test-smk-rBinomDS.R +++ b/tests/testthat/test-smk-rBinomDS.R @@ -15,6 +15,8 @@ # context("rBinomDS::smk::setup") +set.standard.disclosure.settings() + # # Tests # @@ -58,6 +60,14 @@ test_that("simple rBinomDS, direct", { expect_true(res[8] >= 0) }) +test_that("rBinomDS fails when size references nonexistent object", { + expect_error(rBinomDS(8, "nonexistent_obj", 0.5), "does not exist") +}) + +test_that("rBinomDS fails when prob references nonexistent object", { + expect_error(rBinomDS(8, 1, "nonexistent_obj"), "does not exist") +}) + # # Done # diff --git a/tests/testthat/test-smk-rNormDS.R b/tests/testthat/test-smk-rNormDS.R index 484ef851..0182aab6 100644 --- a/tests/testthat/test-smk-rNormDS.R +++ b/tests/testthat/test-smk-rNormDS.R @@ -15,6 +15,8 @@ # context("rNormDS::smk::setup") +set.standard.disclosure.settings() + # # Tests # @@ -58,6 +60,14 @@ test_that("simple rNormDS, direct", { expect_true(res[8] >= 0) }) +test_that("rNormDS fails when mean references nonexistent object", { + expect_error(rNormDS(8, "nonexistent_obj", 1, 9), "does not exist") +}) + +test_that("rNormDS fails when sd references nonexistent object", { + expect_error(rNormDS(8, 0, "nonexistent_obj", 9), "does not exist") +}) + # # Done # diff --git a/tests/testthat/test-smk-rPoisDS.R b/tests/testthat/test-smk-rPoisDS.R index c2cf55bf..ee9de700 100644 --- a/tests/testthat/test-smk-rPoisDS.R +++ b/tests/testthat/test-smk-rPoisDS.R @@ -15,6 +15,8 @@ # context("rPoisDS::smk::setup") +set.standard.disclosure.settings() + # # Tests # @@ -56,6 +58,10 @@ test_that("simple rPoisDS, direct", { expect_true(res[8] >= 0) }) +test_that("rPoisDS fails when lambda references nonexistent object", { + expect_error(rPoisDS(8, "nonexistent_obj"), "does not exist") +}) + # # Done # diff --git a/tests/testthat/test-smk-rUnifDS.R b/tests/testthat/test-smk-rUnifDS.R index 87c208c4..7507db16 100644 --- a/tests/testthat/test-smk-rUnifDS.R +++ b/tests/testthat/test-smk-rUnifDS.R @@ -15,6 +15,8 @@ # context("rUnifDS::smk::setup") +set.standard.disclosure.settings() + # # Tests # @@ -58,6 +60,14 @@ test_that("simple rUnifDS, direct", { expect_true(res[8] >= 0) }) +test_that("rUnifDS fails when min references nonexistent object", { + expect_error(rUnifDS(8, "nonexistent_obj", 1, 9), "does not exist") +}) + +test_that("rUnifDS fails when max references nonexistent object", { + expect_error(rUnifDS(8, 0, "nonexistent_obj", 9), "does not exist") +}) + # # Done # diff --git a/tests/testthat/test-smk-sampleDS.R b/tests/testthat/test-smk-sampleDS.R index e3927518..6fb5cdd9 100644 --- a/tests/testthat/test-smk-sampleDS.R +++ b/tests/testthat/test-smk-sampleDS.R @@ -46,6 +46,16 @@ test_that("simple sampleDS", { expect_length(res$sampling.order, 16) }) +test_that("sampleDS fails when x references nonexistent object", { + expect_error(sampleDS("nonexistent_obj", 5, FALSE, NULL), "does not exist") +}) + +test_that("sampleDS fails when prob references nonexistent object", { + x <- c(1:32) + + expect_error(sampleDS("x", 5, FALSE, "nonexistent_obj"), "does not exist") +}) + # # Done # diff --git a/tests/testthat/test-smk-setSeedDS.R b/tests/testthat/test-smk-setSeedDS.R index 0cdbf2e9..0e976bd7 100644 --- a/tests/testthat/test-smk-setSeedDS.R +++ b/tests/testthat/test-smk-setSeedDS.R @@ -15,6 +15,8 @@ # context("setSeedDS::smk::setup") +set.standard.disclosure.settings() + # # Tests # @@ -32,6 +34,14 @@ test_that("simple setSeedDS", { expect_length(res$seed.as.set, 626) }) +test_that("setSeedDS works with numeric string", { + res <- setSeedDS("42", NULL, NULL) + + expect_equal(class(res), "list") + expect_length(res, 1) + expect_length(res$seed.as.set, 626) +}) + # # Done # From 1ee564c0e68137c34a6b202b966ecd185d24b727 Mon Sep 17 00:00:00 2001 From: Tim Cadman <41470917+timcadman@users.noreply.github.com> Date: Thu, 16 Apr 2026 16:43:01 +0200 Subject: [PATCH 2/4] docs: updated authorship --- R/rBinomDS.R | 1 + R/rNormDS.R | 1 + R/rPoisDS.R | 1 + R/rUnifDS.R | 1 + R/sampleDS.R | 1 + R/setSeedDS.R | 1 + 6 files changed, 6 insertions(+) diff --git a/R/rBinomDS.R b/R/rBinomDS.R index bc60cf50..9ec42361 100644 --- a/R/rBinomDS.R +++ b/R/rBinomDS.R @@ -24,6 +24,7 @@ #' also returns a vector reporting the length of the pseudorandom vector #' created in each source. #' @author Paul Burton for DataSHIELD Development Team +#' @author Tim Cadman, Genomics Coordination Centre, UMCG, Netherlands #' @export rBinomDS<-function (n, size = 1, prob = 0.5){ diff --git a/R/rNormDS.R b/R/rNormDS.R index 9184cb24..d201143a 100644 --- a/R/rNormDS.R +++ b/R/rNormDS.R @@ -29,6 +29,7 @@ #' also returns a vector reporting the length of the pseudorandom vector #' created in each source. #' @author Paul Burton for DataSHIELD Development Team +#' @author Tim Cadman, Genomics Coordination Centre, UMCG, Netherlands #' @export rNormDS<-function (n, mean = 0, sd = 1, force.output.to.k.decimal.places=9){ diff --git a/R/rPoisDS.R b/R/rPoisDS.R index 9c42292c..5bee2148 100644 --- a/R/rPoisDS.R +++ b/R/rPoisDS.R @@ -20,6 +20,7 @@ #' also returns a vector reporting the length of the pseudorandom vector #' created in each source. #' @author Paul Burton for DataSHIELD Development Team +#' @author Tim Cadman, Genomics Coordination Centre, UMCG, Netherlands #' @export rPoisDS<-function (n, lambda = 1){ diff --git a/R/rUnifDS.R b/R/rUnifDS.R index 5ca52c55..d20d189f 100644 --- a/R/rUnifDS.R +++ b/R/rUnifDS.R @@ -29,6 +29,7 @@ #' also returns a vector reporting the length of the pseudorandom vector #' created in each source. #' @author Paul Burton for DataSHIELD Development Team +#' @author Tim Cadman, Genomics Coordination Centre, UMCG, Netherlands #' @export rUnifDS<-function (n, min = 0, max = 1, force.output.to.k.decimal.places=9){ diff --git a/R/sampleDS.R b/R/sampleDS.R index ef068916..213451dd 100644 --- a/R/sampleDS.R +++ b/R/sampleDS.R @@ -30,6 +30,7 @@ #' 'newobj.sample') which is written to the serverside. For further details see #' help for ds.sample and native R help for sample(). #' @author Paul Burton, for DataSHIELD Development Team, 15/4/2020 +#' @author Tim Cadman, Genomics Coordination Centre, UMCG, Netherlands #' @export sampleDS <- function(x.transmit, size.transmit, replace.transmit=NULL, prob.transmit=NULL){ diff --git a/R/setSeedDS.R b/R/setSeedDS.R index 75dbace3..bead37b7 100644 --- a/R/setSeedDS.R +++ b/R/setSeedDS.R @@ -32,6 +32,7 @@ #' .Random.seed on each data source that is the true current state of the #' random seed in each source. #' @author Paul Burton for DataSHIELD Development Team +#' @author Tim Cadman, Genomics Coordination Centre, UMCG, Netherlands #' @export setSeedDS<-function (seedtext=NULL, kind = NULL, normal.kind = NULL) { From 70cf83f924cd067cfb7687d26c2e1a6059db5612 Mon Sep 17 00:00:00 2001 From: Tim Cadman <41470917+timcadman@users.noreply.github.com> Date: Thu, 16 Apr 2026 16:46:42 +0200 Subject: [PATCH 3/4] docs: redocumented --- man/rBinomDS.Rd | 2 ++ man/rNormDS.Rd | 2 ++ man/rPoisDS.Rd | 2 ++ man/rUnifDS.Rd | 2 ++ man/sampleDS.Rd | 2 ++ man/setSeedDS.Rd | 2 ++ 6 files changed, 12 insertions(+) diff --git a/man/rBinomDS.Rd b/man/rBinomDS.Rd index 9a3fc25e..b8d16755 100644 --- a/man/rBinomDS.Rd +++ b/man/rBinomDS.Rd @@ -42,4 +42,6 @@ the function rbinom() in native R and its arguments are the same. } \author{ Paul Burton for DataSHIELD Development Team + +Tim Cadman, Genomics Coordination Centre, UMCG, Netherlands } diff --git a/man/rNormDS.Rd b/man/rNormDS.Rd index ef7ea58d..f4dd1f4f 100644 --- a/man/rNormDS.Rd +++ b/man/rNormDS.Rd @@ -48,4 +48,6 @@ the function rnorm() in native R and its arguments are the same. } \author{ Paul Burton for DataSHIELD Development Team + +Tim Cadman, Genomics Coordination Centre, UMCG, Netherlands } diff --git a/man/rPoisDS.Rd b/man/rPoisDS.Rd index 73fcdee0..9d3d2dbe 100644 --- a/man/rPoisDS.Rd +++ b/man/rPoisDS.Rd @@ -37,4 +37,6 @@ and its arguments are the same. } \author{ Paul Burton for DataSHIELD Development Team + +Tim Cadman, Genomics Coordination Centre, UMCG, Netherlands } diff --git a/man/rUnifDS.Rd b/man/rUnifDS.Rd index c9b448ea..f3ad01c8 100644 --- a/man/rUnifDS.Rd +++ b/man/rUnifDS.Rd @@ -48,4 +48,6 @@ the function runif() in native R and its arguments are the same. } \author{ Paul Burton for DataSHIELD Development Team + +Tim Cadman, Genomics Coordination Centre, UMCG, Netherlands } diff --git a/man/sampleDS.Rd b/man/sampleDS.Rd index c3d2ead7..aae770f8 100644 --- a/man/sampleDS.Rd +++ b/man/sampleDS.Rd @@ -54,4 +54,6 @@ help for ds.sample and native R help for sample(). } \author{ Paul Burton, for DataSHIELD Development Team, 15/4/2020 + +Tim Cadman, Genomics Coordination Centre, UMCG, Netherlands } diff --git a/man/setSeedDS.Rd b/man/setSeedDS.Rd index 9c8c2740..6531b5f2 100644 --- a/man/setSeedDS.Rd +++ b/man/setSeedDS.Rd @@ -50,4 +50,6 @@ theoretical work with random number generators it is likely that the } \author{ Paul Burton for DataSHIELD Development Team + +Tim Cadman, Genomics Coordination Centre, UMCG, Netherlands } From 7ffc44d55c42482fe4e8b3a8e667ba765b1ba1c9 Mon Sep 17 00:00:00 2001 From: Tim Cadman <41470917+timcadman@users.noreply.github.com> Date: Mon, 14 Sep 2026 12:47:31 +0200 Subject: [PATCH 4/4] fixed tests and docs --- R/rBinomDS.R | 11 +++-------- R/rNormDS.R | 12 ++++-------- R/rPoisDS.R | 11 +++-------- R/rUnifDS.R | 12 ++++-------- man/rBinomDS.Rd | 11 +++-------- man/rNormDS.Rd | 12 ++++-------- man/rPoisDS.Rd | 11 +++-------- man/rUnifDS.Rd | 12 ++++-------- tests/testthat/test-smk-setSeedDS.R | 8 ++++++-- 9 files changed, 34 insertions(+), 66 deletions(-) diff --git a/R/rBinomDS.R b/R/rBinomDS.R index 9ec42361..a79428f6 100644 --- a/R/rBinomDS.R +++ b/R/rBinomDS.R @@ -15,14 +15,9 @@ #' by argument of ds.rBinom - for details see help for ds.rBinom #' May be a scalar or a vector allowing the size to vary from #' observation to observation. -#' @return Writes the pseudorandom number vector with the characteristics specified -#' in the function call as a new serverside vector on the data source on which -#' it has been called. Also returns key information to the clientside: -#' the random seed as specified by you in each -#' source + (if requested) the full 626 length random seed vector this generated in -#' each source (see info for the argument ). It -#' also returns a vector reporting the length of the pseudorandom vector -#' created in each source. +#' @return the vector of pseudorandom numbers from a binomial distribution, which +#' is written to the serverside as the object named by the argument +#' of ds.rBinom. #' @author Paul Burton for DataSHIELD Development Team #' @author Tim Cadman, Genomics Coordination Centre, UMCG, Netherlands #' @export diff --git a/R/rNormDS.R b/R/rNormDS.R index d201143a..c0795201 100644 --- a/R/rNormDS.R +++ b/R/rNormDS.R @@ -20,14 +20,10 @@ #' have k decimal places. If k = 9, no rounding occurs of native output. #' Default=9. Value specified by argument #' in ds.rNorm -#' @return Writes the pseudorandom number vector with the characteristics specified -#' in the function call as a new serverside vector on the data source on which -#' it has been called. Also returns key information to the clientside: -#' the random seed as specified by you in each -#' source + (if requested) the full 626 length random seed vector this generated in -#' each source (see info for the argument ). It -#' also returns a vector reporting the length of the pseudorandom vector -#' created in each source. +#' @return the numeric vector of pseudorandom numbers from a normal distribution, +#' rounded to decimal places if that is less +#' than 9, which is written to the serverside as the object named by the +#' argument of ds.rNorm. #' @author Paul Burton for DataSHIELD Development Team #' @author Tim Cadman, Genomics Coordination Centre, UMCG, Netherlands #' @export diff --git a/R/rPoisDS.R b/R/rPoisDS.R index 5bee2148..a7bf9533 100644 --- a/R/rPoisDS.R +++ b/R/rPoisDS.R @@ -11,14 +11,9 @@ #' distribution used to generate the random counts. Specified directly #' by the lambda argument in ds.rPois. May be a scalar or a vector allowing lambda #' to vary from observation to observation. -#' @return Writes the pseudorandom number vector with the characteristics specified -#' in the function call as a new serverside vector on the data source on which -#' it has been called. Also returns key information to the clientside: -#' the random seed as specified by you in each -#' source + (if requested) the full 626 length random seed vector this generated in -#' each source (see info for the argument ). It -#' also returns a vector reporting the length of the pseudorandom vector -#' created in each source. +#' @return the vector of pseudorandom non-negative integers from a Poisson +#' distribution, which is written to the serverside as the object named by the +#' argument of ds.rPois. #' @author Paul Burton for DataSHIELD Development Team #' @author Tim Cadman, Genomics Coordination Centre, UMCG, Netherlands #' @export diff --git a/R/rUnifDS.R b/R/rUnifDS.R index d20d189f..1e9c9c10 100644 --- a/R/rUnifDS.R +++ b/R/rUnifDS.R @@ -20,14 +20,10 @@ #' have k decimal places. If k = 9, no rounding occurs of native output. #' Default=9. Value specified by argument #' in ds.rUnif -#' @return Writes the pseudorandom number vector with the characteristics specified -#' in the function call as a new serverside vector on the data source on which -#' it has been called. Also returns key information to the clientside: -#' the random seed as specified by you in each -#' source + (if requested) the full 626 length random seed vector this generated in -#' each source (see info for the argument ). It -#' also returns a vector reporting the length of the pseudorandom vector -#' created in each source. +#' @return the numeric vector of pseudorandom numbers from a uniform distribution, +#' rounded to decimal places if that is less +#' than 9, which is written to the serverside as the object named by the +#' argument of ds.rUnif. #' @author Paul Burton for DataSHIELD Development Team #' @author Tim Cadman, Genomics Coordination Centre, UMCG, Netherlands #' @export diff --git a/man/rBinomDS.Rd b/man/rBinomDS.Rd index b8d16755..11c527a0 100644 --- a/man/rBinomDS.Rd +++ b/man/rBinomDS.Rd @@ -22,14 +22,9 @@ May be a scalar or a vector allowing the size to vary from observation to observation.} } \value{ -Writes the pseudorandom number vector with the characteristics specified -in the function call as a new serverside vector on the data source on which -it has been called. Also returns key information to the clientside: -the random seed as specified by you in each -source + (if requested) the full 626 length random seed vector this generated in -each source (see info for the argument ). It -also returns a vector reporting the length of the pseudorandom vector -created in each source. +the vector of pseudorandom numbers from a binomial distribution, which +is written to the serverside as the object named by the argument +of ds.rBinom. } \description{ primary serverside assign function called by ds.rBinom diff --git a/man/rNormDS.Rd b/man/rNormDS.Rd index f4dd1f4f..2ae0d082 100644 --- a/man/rNormDS.Rd +++ b/man/rNormDS.Rd @@ -28,14 +28,10 @@ Default=9. Value specified by argument in ds.rNorm} } \value{ -Writes the pseudorandom number vector with the characteristics specified -in the function call as a new serverside vector on the data source on which -it has been called. Also returns key information to the clientside: -the random seed as specified by you in each -source + (if requested) the full 626 length random seed vector this generated in -each source (see info for the argument ). It -also returns a vector reporting the length of the pseudorandom vector -created in each source. +the numeric vector of pseudorandom numbers from a normal distribution, +rounded to decimal places if that is less +than 9, which is written to the serverside as the object named by the +argument of ds.rNorm. } \description{ primary serverside assign function called by ds.rNorm diff --git a/man/rPoisDS.Rd b/man/rPoisDS.Rd index 9d3d2dbe..d6c6edc1 100644 --- a/man/rPoisDS.Rd +++ b/man/rPoisDS.Rd @@ -16,14 +16,9 @@ by the lambda argument in ds.rPois. May be a scalar or a vector allowing lambda to vary from observation to observation.} } \value{ -Writes the pseudorandom number vector with the characteristics specified -in the function call as a new serverside vector on the data source on which -it has been called. Also returns key information to the clientside: -the random seed as specified by you in each -source + (if requested) the full 626 length random seed vector this generated in -each source (see info for the argument ). It -also returns a vector reporting the length of the pseudorandom vector -created in each source. +the vector of pseudorandom non-negative integers from a Poisson +distribution, which is written to the serverside as the object named by the + argument of ds.rPois. } \description{ primary serverside assign function called by ds.rPois diff --git a/man/rUnifDS.Rd b/man/rUnifDS.Rd index f3ad01c8..491bcd07 100644 --- a/man/rUnifDS.Rd +++ b/man/rUnifDS.Rd @@ -28,14 +28,10 @@ Default=9. Value specified by argument in ds.rUnif} } \value{ -Writes the pseudorandom number vector with the characteristics specified -in the function call as a new serverside vector on the data source on which -it has been called. Also returns key information to the clientside: -the random seed as specified by you in each -source + (if requested) the full 626 length random seed vector this generated in -each source (see info for the argument ). It -also returns a vector reporting the length of the pseudorandom vector -created in each source. +the numeric vector of pseudorandom numbers from a uniform distribution, +rounded to decimal places if that is less +than 9, which is written to the serverside as the object named by the +argument of ds.rUnif. } \description{ primary serverside assign function called by ds.rUnif diff --git a/tests/testthat/test-smk-setSeedDS.R b/tests/testthat/test-smk-setSeedDS.R index 0e976bd7..a87ab40b 100644 --- a/tests/testthat/test-smk-setSeedDS.R +++ b/tests/testthat/test-smk-setSeedDS.R @@ -34,14 +34,18 @@ test_that("simple setSeedDS", { expect_length(res$seed.as.set, 626) }) -test_that("setSeedDS works with numeric string", { - res <- setSeedDS("42", NULL, NULL) +test_that("setSeedDS with \"NULL\" seedtext", { + res <- setSeedDS("NULL", NULL, NULL) expect_equal(class(res), "list") expect_length(res, 1) expect_length(res$seed.as.set, 626) }) +test_that("setSeedDS fails with non-numeric seedtext", { + expect_error(suppressWarnings(setSeedDS("abc", NULL, NULL)), "supplied seed is not a valid integer") +}) + # # Done #