From a1ae321e2a5c42a0c869dfc11b07a1acb38be0ec Mon Sep 17 00:00:00 2001 From: jbytecode Date: Wed, 27 Jul 2022 22:22:21 +0300 Subject: [PATCH] update version, doc, and tests --- DESCRIPTION | 4 ++-- man/cga_generate_chromosome.Rd | 9 ++++++--- tests/testthat/test-cga.R | 17 ++++++++++------- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 7121eb5..3619ba4 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -2,7 +2,7 @@ Package: eive Type: Package Title: An Algorithm for Reducing Errors-in-Variable Bias in Simple Linear Regression -Version: 3.1 +Version: 3.1.0 Date: 2022-07-22 Author: Mehmet Hakan Satman (Ph.D.), Erkin Diyarbakirlioglu (Ph.D.) Maintainer: Mehmet Hakan Satman @@ -16,4 +16,4 @@ Repository: CRAN Date/Publication: 2018-05-16 21:38:11 UTC Suggests: testthat -RoxygenNote: 7.2.0 +RoxygenNote: 7.2.1 diff --git a/man/cga_generate_chromosome.Rd b/man/cga_generate_chromosome.Rd index 8828ca8..323d4fa 100644 --- a/man/cga_generate_chromosome.Rd +++ b/man/cga_generate_chromosome.Rd @@ -7,13 +7,16 @@ cga_generate_chromosome Generates vector of zeros and ones for a given probability vector. } \usage{ -cga_generate_chromosome(prob_vec) +cga_generate_chromosome(prob_vec, vect) } %- maybe also 'usage' for other objects documented here. \arguments{ - \item{prob_vec}{ +\item{prob_vec}{ Vector of probabilities. } +\item{vect}{ +Integer vector with the same number elements of probabilities. The returned 0-1 vector is held by this variable. +} } \details{ This function is not directly called by user. CGA (Compact genetic algorithms) sample chromosomes using this probability vector. @@ -22,7 +25,7 @@ of BK having the value of 1 is PK. So, it has more chance to have [1,1,1,0,0] th [0.9,0.9,0.9,0.1,0.1]. } \value{ -Returns the generated chromosome for a given probability vector. Return type is vector. +Returns NULL. The wrapped C++ function returns void. The result is held by the `vect` argument. } \author{ Mehmet Hakan Satman diff --git a/tests/testthat/test-cga.R b/tests/testthat/test-cga.R index f5f045a..c1107dd 100644 --- a/tests/testthat/test-cga.R +++ b/tests/testthat/test-cga.R @@ -29,11 +29,14 @@ test_that("CGA - All 100 bits are 0s", { }) test_that("CGA - Generate Chromosome", { - probs <- rep(0.5, 10) - v <- rep(0, 10) - cga_generate_chromosome(probs, v) - for (element in v) { - expect_gte(element, 0.0) - expect_lte(element, 1.0) - } + probs <- rep(0.5, 1000) + v <- rep(0, 1000) + result <- cga_generate_chromosome(probs, v) + + # Function returns NULL + expect_null(result) + + # Not all of the values are same + expect_false(all(v == 0)) + expect_false(all(v == 1)) }) \ No newline at end of file