tests/weightedVar_etal_subset.R

library("matrixStats")

fcns <- list(
  weightedVar = weightedVar,
  weightedSd  = weightedSd,
  weightedMad = weightedMad
)


# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Subsetted tests
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
source("utils/validateIndicesFramework.R")
for (name in names(fcns)) {
  cat(sprintf("subsetted tests on %s()...\n", name))
  fcn <- fcns[[name]]

  for (mode in c("numeric", "integer")) {
    x <- runif(6, min = -6, max = 6)
    w <- runif(6, min = 0, max = 6)
    storage.mode(x) <- mode
    storage.mode(w) <- mode
    if (mode == "numeric") w[1] <- Inf

    for (idxs in index_cases) {
      validateIndicesTestVector_w(x, w, idxs,
                                  ftest = fcn, fsure = fcn,
                                  na.rm = TRUE)
      validateIndicesTestVector_w(x, w, idxs,
                                  ftest = fcn, fsure = fcn,
                                  na.rm = FALSE)
    }
  }
  cat(sprintf("%s()...DONE\n", name))
}
HenrikBengtsson/matrixStats documentation built on Nov. 15, 2024, 3:20 p.m.