diff --git a/DESCRIPTION b/DESCRIPTION index a2f1ddfc..8214915b 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: matrixStats -Version: 1.2.0-9016 +Version: 1.2.0-9017 Depends: R (>= 2.12.0) Suggests: diff --git a/R/000.DEPRECATION.R b/R/000.DEPRECATION.R index 5503e724..a2eb98a4 100644 --- a/R/000.DEPRECATION.R +++ b/R/000.DEPRECATION.R @@ -47,8 +47,7 @@ validateScalarCenter <- function(center, n, dimname) { validateVarsCenterFormula <- local({ - .curr <- 1 - .next <- 1 + countdown <- NA_integer_ always <- structure(TRUE, when = "each time this function is called") function() { @@ -66,13 +65,12 @@ validateVarsCenterFormula <- local({ ## each time? if (freq == 1) return(always) - ## once in a while? - .curr <<- .curr + 1 - .next <<- freq ## update .next according to R option - - ## Skip or not? - if (.curr <= .next) return(FALSE) - .curr <<- 1 ## reset + ## Not first incident? + if (!is.na(countdown)) { + countdown <<- countdown - 1L + if (countdown > 0L) return(FALSE) + } + countdown <<- freq ## reset structure(TRUE, when = sprintf("every %g call to this function", freq)) } }) @@ -100,8 +98,7 @@ centerOnUse <- function(fcnname, calls = sys.calls(), msg = NULL) { validateTiesMethodMissing <- local({ - .curr <- 1 - .next <- 1 + countdown <- NA_integer_ always <- structure(TRUE, when = "each time this function is called") function() { @@ -117,15 +114,14 @@ validateTiesMethodMissing <- local({ if (is.infinite(freq)) return(always) ## each time? - if (freq == 1) return(always) - - ## once in a while? - .curr <<- .curr + 1 - .next <<- freq ## update .next according to R option - - ## Skip or not? - if (.curr <= .next) return(FALSE) - .curr <<- 1 ## reset + if (freq == 1L) return(always) + + ## Not first incident? + if (!is.na(countdown)) { + countdown <<- countdown - 1L + if (countdown > 0L) return(FALSE) + } + countdown <<- freq ## reset structure(TRUE, when = sprintf("every %g call to this function", freq)) } }) diff --git a/R/options.R b/R/options.R index 603d9087..a1729c86 100644 --- a/R/options.R +++ b/R/options.R @@ -38,7 +38,7 @@ #' \describe{ #' \item{\option{matrixStats.formula.freq}:}{(numeric) #' Controls how often the above assumption is checked. -#' (Default: \code{50} - every 50th call)} +#' (Default: \code{50} - every 50:th call starting with the first)} #' } #' #' \describe{ @@ -54,7 +54,7 @@ #' \describe{ #' \item{\option{matrixStats.ties.method.freq}:}{(numeric) #' Controls how often the above validation is checked. -#' (Default: \code{50} - every 50th call)} +#' (Default: \code{50} - every 50:th call starting with the first)} #' } #' #' \describe{