R Under development (unstable) (2024-09-02 r87090 ucrt) -- "Unsuffered Consequences" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > library("matrixStats") > > # - - - - - - - - - - - - - - - - - - - - - - - - - - > # Subsetted tests > # - - - - - - - - - - - - - - - - - - - - - - - - - - > source("utils/validateIndicesFramework.R") > x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) > #W <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) > for (rows in index_cases) { + for (cols in index_cases) { + if (is.null(rows)) { + rows <- seq_len(nrow(x)) + rows_finite <- rows + } else { + rows_finite <- rows[is.finite(rows)] + } + + if (is.null(cols)) { + cols <- seq_len(ncol(x)) + cols_finite <- cols + } else { + cols_finite <- cols[is.finite(cols)] + } + + suppressWarnings({ + actual <- tryCatch({ + rowAvgsPerColSet(x, rows = rows, S = matrix(cols, ncol = 1), + FUN = rowMeans) + }, error = function(c) "error") + expect <- tryCatch({ + rowMeans(x[rows, cols_finite, drop = FALSE], na.rm = TRUE) + }, error = function(c) "error") + }) + stopifnot(all.equal(as.vector(actual), expect)) + + suppressWarnings({ + actual <- tryCatch({ + colAvgsPerRowSet(x, cols = cols, S = matrix(rows, ncol = 1), + FUN = colMeans) + }, error = function(c) "error") + expect <- tryCatch({ + colMeans(x[rows_finite, cols, drop = FALSE], na.rm = TRUE) + }, error = function(c) "error") + }) + stopifnot(all.equal(as.vector(actual), expect)) + } + } > > proc.time() user system elapsed 0.56 0.04 0.54