Skip to content

Commit

Permalink
Deprecation/defunct message that are only produced once in a while no…
Browse files Browse the repository at this point in the history
…w starts with the first incident
  • Loading branch information
HenrikBengtsson committed Apr 10, 2024
1 parent 7fefc70 commit 9c28f14
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 23 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: matrixStats
Version: 1.2.0-9016
Version: 1.2.0-9017
Depends:
R (>= 2.12.0)
Suggests:
Expand Down
36 changes: 16 additions & 20 deletions R/000.DEPRECATION.R
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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))
}
})
Expand Down Expand Up @@ -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() {
Expand All @@ -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))
}
})
Expand Down
4 changes: 2 additions & 2 deletions R/options.R
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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{
Expand Down

0 comments on commit 9c28f14

Please sign in to comment.