Skip to content

Commit

Permalink
update version, doc, and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jbytecode committed Jul 27, 2022
1 parent 61430b5 commit a1ae321
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -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 <mhsatman@istanbul.edu.tr>
Expand All @@ -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
9 changes: 6 additions & 3 deletions man/cga_generate_chromosome.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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 <mhsatman@istanbul.edu.tr>
Expand Down
17 changes: 10 additions & 7 deletions tests/testthat/test-cga.R
Original file line number Diff line number Diff line change
Expand Up @@ -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))
})

0 comments on commit a1ae321

Please sign in to comment.