R/resetEvaluationCounter.R

Defines functions resetEvaluationCounter.smoof_wrapped_function resetEvaluationCounter.smoof_counting_function resetEvaluationCounter

Documented in resetEvaluationCounter

#' Reset evaluation counter.
#'
#' @param fn [\code{smoof_counting_function}]\cr
#'   Wrapped \code{smoof_function}.
#' @export
resetEvaluationCounter = function(fn) {
  UseMethod("resetEvaluationCounter")
}

#' @export
resetEvaluationCounter.smoof_counting_function = function(fn) {
  environment(fn)$n.evals = 0L
}

#' @export
resetEvaluationCounter.smoof_wrapped_function = function(fn) {
  return(resetEvaluationCounter(getWrappedFunction(fn)))
}
jakobbossek/smoof documentation built on Feb. 17, 2024, 2:23 a.m.