Skip to content

Commit

Permalink
* R/normalise.R: rename to.range to to_range.
Browse files Browse the repository at this point in the history
  • Loading branch information
MLopez-Ibanez committed Sep 12, 2023
1 parent 0360054 commit 7f6df7b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# development version

* The argument `to.range` of `normalise()` has been renamed to `to_range`.

# eaf 2.5

* Silence some warnings with GCC 12.
Expand Down
14 changes: 7 additions & 7 deletions R/normalise.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
#'
#' @template arg_data
#'
#' @param to.range Normalise values to this range. If the objective is
#' maximised, it is normalised to \code{c(to.range[1], to.range[0])}
#' @param to_range Normalise values to this range. If the objective is
#' maximised, it is normalised to \code{c(to_range[1], to_range[0])}
#' instead.
#'
#' @param lower,upper Bounds on the values. If NA, the maximum and minimum
Expand All @@ -27,10 +27,10 @@
#'
#' head(normalise(SPEA2minstoptimeRichmond[, 1:2], maximise = c(FALSE, TRUE)))
#'
#' head(normalise(SPEA2minstoptimeRichmond[, 1:2], to.range = c(0,1), maximise = c(FALSE, TRUE)))
#' head(normalise(SPEA2minstoptimeRichmond[, 1:2], to_range = c(0,1), maximise = c(FALSE, TRUE)))
#'
#' @export
normalise <- function(data, to.range = c(1, 2), lower = NA, upper = NA, maximise = FALSE)
normalise <- function(data, to_range = c(1, 2), lower = NA, upper = NA, maximise = FALSE)
{
data <- check_dataset(data)
nobjs <- ncol(data)
Expand All @@ -45,14 +45,14 @@ normalise <- function(data, to.range = c(1, 2), lower = NA, upper = NA, maximise
upper[no.upper] <- minmax[no.upper, 2L]
maximise <- as.logical(rep_len(maximise, nobjs))

if (length(to.range) != 2L)
stop("to.range must be a vector of length 2")
if (length(to_range) != 2L)
stop("to_range must be a vector of length 2")

z <- t(.Call(normalise_C,
as.double(t(data)),
as.integer(nobjs),
as.integer(npoints),
as.double(to.range),
as.double(to_range),
lower, upper, maximise))
colnames(z) <- colnames(data)
rownames(z) <- rownames(data)
Expand Down
8 changes: 4 additions & 4 deletions man/normalise.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/testthat/test-normalise.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ test_that("normalise", {
expect_equal(normalise(x, maximise = c(FALSE,TRUE)),
my.2d.matrix(1, 1.5, 2, 2, 1.5, 1))

expect_equal(normalise(x, to.range = c(0, 1), maximise = c(FALSE,TRUE)),
expect_equal(normalise(x, to_range = c(0, 1), maximise = c(FALSE,TRUE)),
my.2d.matrix(0, 0.5, 1, 1, 0.5, 0))

expect_equal(normalise(my.2d.matrix(1,1,2,2)), my.2d.matrix(1,1,1,1))
Expand Down

0 comments on commit 7f6df7b

Please sign in to comment.