Running ‘allocArray.R’
  Running ‘allocMatrix.R’
  Running ‘allocVector.R’
  Running ‘anyMissing.R’
  Running ‘anyMissing_subset.R’
  Running ‘benchmark.R’ [18s/24s]
  Running ‘binCounts.R’
  Running ‘binCounts_subset.R’
  Running ‘binMeans,binCounts.R’
  Running ‘binMeans,binCounts_subset.R’
  Running ‘count.R’
  Running ‘count_subset.R’
  Running ‘diff2.R’
  Running ‘diff2_subset.R’
  Running ‘indexByRow.R’
  Running ‘logSumExp.R’
  Running ‘logSumExp_subset.R’
  Running ‘mean2.R’
  Running ‘mean2_subset.R’
  Running ‘product.R’
  Running ‘product_subset.R’
  Running ‘psortKM.R’
  Running ‘rowAllAnys.R’
  Running ‘rowAllAnys_subset.R’ [24s/32s]
  Running ‘rowAvgsPerColSet.R’
  Running ‘rowAvgsPerColSet_subset.R’
  Running ‘rowCollapse.R’
  Running ‘rowCollapse_subset.R’
  Running ‘rowCounts.R’
  Running ‘rowCounts_subset.R’ [12s/15s]
  Running ‘rowCumMinMaxs.R’
  Running ‘rowCumMinMaxs_subset.R’
  Running ‘rowCumprods.R’
  Running ‘rowCumprods_subset.R’
  Running ‘rowCumsums.R’
  Running ‘rowCumsums_subset.R’
  Running ‘rowDiffs.R’
  Running ‘rowDiffs_subset.R’ [9s/11s]
  Running ‘rowIQRs.R’
  Running ‘rowIQRs_subset.R’
  Running ‘rowLogSumExps.R’
  Running ‘rowLogSumExps_subset.R’
  Running ‘rowMads.R’
  Running ‘rowMads_subset.R’
  Running ‘rowMeans2.R’
  Running ‘rowMeans2_subset.R’
  Running ‘rowMedians.R’
  Running ‘rowMedians_subset.R’
  Running ‘rowOrderStats.R’
  Running ‘rowOrderStats_subset.R’
  Running ‘rowProds.R’
  Running ‘rowProds_subset.R’
  Running ‘rowQuantiles.R’ [49s/61s]
  Running ‘rowQuantiles_subset.R’
  Running ‘rowRanges.R’
  Running ‘rowRanges_subset.R’
  Running ‘rowRanks.R’ [18s/23s]
  Running ‘rowRanks_subset.R’
  Running ‘rowSds.R’
  Running ‘rowSds_subset.R’
  Running ‘rowSums2.R’
  Running ‘rowSums2_subset.R’
  Running ‘rowTabulates.R’
  Running ‘rowTabulates_subset.R’
  Running ‘rowVarDiffs.R’
  Running ‘rowVarDiffs_mad,iqr_subset.R’ [17s/18s]
  Running ‘rowVarDiffs_var,sd_subset.R’ [13s/15s]
  Running ‘rowVars.R’
  Running ‘rowVars_subset.R’
  Running ‘rowWeightedMeans.R’
  Running ‘rowWeightedMeans_subset.R’
  Running ‘rowWeightedMedians.R’
  Running ‘rowWeightedMedians_subset.R’
  Running ‘rowWeightedVars.R’
  Running ‘rowWeightedVars_subset.R’ [9s/12s]
  Running ‘signTabulate.R’
  Running ‘signTabulate_subset.R’
  Running ‘sum2.R’
  Running ‘sum2_subset.R’
  Running ‘validateIndices.R’
  Running ‘varDiff_etal.R’
  Running ‘varDiff_etal_subset.R’
  Running ‘weightedMean.R’
  Running ‘weightedMean_subset.R’
  Running ‘weightedMedian.R’
  Running ‘weightedMedian_subset.R’
  Running ‘weightedVar.R’
  Running ‘weightedVar_etal.R’
  Running ‘weightedVar_etal_subset.R’
  Running ‘x_OP_y.R’
  Running ‘x_OP_y_subset.R’ [14s/18s]
  Running ‘zzz.package-unload.R’
Running the tests in ‘tests/rowCumMinMaxs.R’ failed.
Complete output:
  > library("matrixStats")
  > 
  > rowCummins_R <- function(x, ..., useNames = NA) {
  +   suppressWarnings({
  +     y <- t(apply(x, MARGIN = 1L, FUN = cummin))
  +   })
  +   
  +   # Preserve dimnames attribute?
  +   dim(y) <- dim(x)
  +   dimnames <- dimnames(x)
  +   if (isTRUE(useNames) && !is.null(dimnames)) dimnames(y) <- dimnames  
  +   
  +   y
  + }
  > 
  > rowCummaxs_R <- function(x, ..., useNames = NA) {
  +   mode <- storage.mode(x)
  +   # Change mode because a bug is detected on cummax for integer in R-3.2.0
  +   storage.mode(x) <- "numeric"
  +   suppressWarnings({
  +     y <- t(apply(x, MARGIN = 1L, FUN = cummax))
  +   })
  +   
  +   # Preserve dimnames attribute?
  +   dim(y) <- dim(x)
  +   dimnames <- dimnames(x)
  +   if (isTRUE(useNames) && !is.null(dimnames)) dimnames(y) <- dimnames  
  +   
  +   y
  + }
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # With and without some NAs
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > for (mode in c("logical", "integer", "double")) {
  +   for (add_na in c(FALSE, TRUE)) {
  +     cat("add_na = ", add_na, "\n", sep = "")
  + 
  +     x <- matrix(1:50, nrow = 10L, ncol = 5L)
  +     diag(x) <- 0
  +     if (add_na) {
  +       x[3:7, c(2, 4)] <- NA_real_
  +     }
  +     cat("mode: ", mode, "\n", sep = "")
  +     storage.mode(x) <- mode
  +     str(x)
  +     
  +     # To check dimnames attribute
  +     dimnames <- list(letters[1:10], LETTERS[1:5])
  +     
  +     # Test with and without dimnames on x
  +     for (setDimnames in c(TRUE, FALSE)) {
  +       if (setDimnames) dimnames(x) <- dimnames
  +       else dimnames(x) <- NULL    
  +       # Check names attribute
  +       for (useNames in c(NA, TRUE, FALSE)) {
  +         # Row/column ranges
  +         r0 <- rowCummins_R(x, useNames = useNames)
  +         r1 <- rowCummins(x, useNames = useNames)
  +         r2 <- t(colCummins(t(x), useNames = useNames))
  +         stopifnot(all.equal(r1, r2))
  +         stopifnot(all.equal(r1, r0))
  +         stopifnot(all.equal(r2, r0))
  +         
  +         r0 <- rowCummaxs_R(x, useNames = useNames)
  +         r1 <- rowCummaxs(x, useNames = useNames)
  +         r2 <- t(colCummaxs(t(x), useNames = useNames))
  +         stopifnot(all.equal(r1, r2))
  +         stopifnot(all.equal(r1, r0))
  +         stopifnot(all.equal(r2, r0))
  +       } # for (useNames ...)
  +     } # for (setDimnames ...)
  +   } # for (add_na ...)
  + } # for (mode ...)
  add_na = FALSE
  mode: logical
   logi [1:10, 1:5] FALSE TRUE TRUE TRUE TRUE TRUE ...
  Error: r1 and r0 are not equal:
    Attributes: < Length mismatch: comparison on first 1 components >
  In addition: Warning messages:
  1: useNames = NA is deprecated. Instead, specify either useNames = TRUE or useNames = TRUE. 
  2: useNames = NA is deprecated. Instead, specify either useNames = TRUE or useNames = TRUE. 
  Execution halted
Running the tests in ‘tests/rowCumMinMaxs_subset.R’ failed.
Complete output:
  > library("matrixStats")
  > 
  > rowCummins_R <- function(x, ..., useNames = NA) {
  +   suppressWarnings({
  +     y <- t(apply(x, MARGIN = 1L, FUN = cummin))
  +   })
  +   
  +   # Preserve dimnames attribute?
  +   dim(y) <- dim(x)
  +   dimnames <- dimnames(x)
  +   if (isTRUE(useNames) && !is.null(dimnames)) dimnames(y) <- dimnames  
  +   
  +   y
  + }
  > 
  > rowCummaxs_R <- function(x, ..., useNames = NA) {
  +   mode <- storage.mode(x)
  +   # Change mode because a bug is detected on cummax for integer in R-3.2.0
  +   storage.mode(x) <- "numeric"
  +   suppressWarnings({
  +     y <- t(apply(x, MARGIN = 1L, FUN = cummax))
  +   })
  +   
  +   # Preserve dimnames attribute?
  +   dim(y) <- dim(x)
  +   dimnames <- dimnames(x)
  +   if (isTRUE(useNames) && !is.null(dimnames)) dimnames(y) <- dimnames  
  +   
  +   storage.mode(y) <- mode
  +   y
  + }
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # Subsetted tests
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > source("utils/validateIndicesFramework.R")
  > x <- matrix(runif(6 * 6, min = -3, max = 3), nrow = 6, ncol = 6)
  > storage.mode(x) <- "integer"
  > 
  > # To check dimnames attribute
  > dimnames <- list(letters[1:6], LETTERS[1:6])
  > 
  > # Test with and without dimnames on x
  > for (setDimnames in c(TRUE, FALSE)) {
  +   if (setDimnames) dimnames(x) <- dimnames
  +   else dimnames(x) <- NULL
  +   for (rows in index_cases) {
  +     for (cols in index_cases) {
  +       # Check names attribute
  +       for (useNames in c(NA, TRUE, FALSE)) {
  +         validateIndicesTestMatrix(x, rows, cols,
  +                                   ftest = rowCummins, fsure = rowCummins_R, useNames = useNames,verbose=TRUE)
  +         validateIndicesTestMatrix(x, rows, cols,
  +                                   ftest = function(x, rows, cols, ..., useNames) {
  +           t(colCummins(t(x), rows = cols, cols = rows, useNames = useNames))
  +         }, fsure = rowCummins_R, useNames = useNames)
  + 
  +         validateIndicesTestMatrix(x, rows, cols,
  +                                   ftest = rowCummaxs, fsure = rowCummaxs_R, useNames = useNames)
  +         validateIndicesTestMatrix(x, rows, cols,
  +                                   ftest = function(x, rows, cols, ..., useNames) {
  +           t(colCummaxs(t(x), rows = cols, cols = rows, useNames = useNames))
  +         }, fsure = rowCummaxs_R, useNames = useNames)
  +       }
  +     }
  +   }
  + }
  Error in validateIndicesTestMatrix(x, rows, cols, ftest = rowCummins,  : 
    actual and expect are not equal:
    Attributes: < Length mismatch: comparison on first 1 components >
  Calls: validateIndicesTestMatrix -> stopifnot
  Execution halted
Running the tests in ‘tests/rowCumprods.R’ failed.
Complete output:
  > library("matrixStats")
  > 
  > rowCumprods_R <- function(x, ..., useNames = NA) {
  +   suppressWarnings({
  +     y <- t(apply(x, MARGIN = 1L, FUN = cumprod))
  +   })
  +   
  +   # Preserve dimnames attribute?
  +   dim(y) <- dim(x)
  +   dimnames <- dimnames(x)
  +   if (isTRUE(useNames) && !is.null(dimnames)) dimnames(y) <- dimnames  
  +   
  +   y
  + }
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # With and without some NAs
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > for (mode in c("logical", "integer", "double")) {
  +   for (add_na in c(FALSE, TRUE)) {
  +     cat("add_na = ", add_na, "\n", sep = "")
  + 
  +     x <- matrix(1:50, nrow = 10L, ncol = 5L)
  +     if (add_na) {
  +       x[3:7, c(2, 4)] <- NA_real_
  +     }
  +     cat("mode: ", mode, "\n", sep = "")
  +     storage.mode(x) <- mode
  +     str(x)
  +     
  +     # To check dimnames attribute
  +     dimnames <- list(letters[1:10], LETTERS[1:5])
  +     
  +     # Test with and without dimnames on x
  +     for (setDimnames in c(TRUE, FALSE)) {
  +       if (setDimnames) dimnames(x) <- dimnames
  +       else dimnames(x) <- NULL    
  +       # Check names attribute
  +       for (useNames in c(NA, TRUE, FALSE)) {
  +         # Row/column ranges
  +         r0 <- rowCumprods_R(x, useNames = useNames)
  +         r1 <- rowCumprods(x, useNames = useNames)
  +         r2 <- t(colCumprods(t(x), useNames = useNames))
  +         stopifnot(all.equal(r1, r2))
  +         stopifnot(all.equal(r1, r0))
  +         stopifnot(all.equal(r2, r0))
  +       } # for (useNames ...)
  +     } # for (setDimnames ...)
  +   } # for (add_na ...)
  + } # for (mode ...)
  add_na = FALSE
  mode: logical
   logi [1:10, 1:5] TRUE TRUE TRUE TRUE TRUE TRUE ...
  Error: r1 and r0 are not equal:
    Attributes: < Length mismatch: comparison on first 1 components >
  In addition: Warning messages:
  1: useNames = NA is deprecated. Instead, specify either useNames = TRUE or useNames = TRUE. 
  2: useNames = NA is deprecated. Instead, specify either useNames = TRUE or useNames = TRUE. 
  Execution halted
Running the tests in ‘tests/rowCumprods_subset.R’ failed.
Complete output:
  > library("matrixStats")
  > 
  > rowCumprods_R <- function(x, ..., useNames = NA) {
  +   suppressWarnings({
  +     y <- t(apply(x, MARGIN = 1L, FUN = cumprod))
  +   })
  + 
  +   # Preserve dimnames attribute?
  +   dim(y) <- dim(x)
  +   dimnames <- dimnames(x)
  +   if (isTRUE(useNames) && !is.null(dimnames)) dimnames(y) <- dimnames  
  +   
  +   y
  + }
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # Subsetted tests
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > source("utils/validateIndicesFramework.R")
  > x <- matrix(runif(6 * 6, min = -3, max = 3), nrow = 6, ncol = 6)
  > storage.mode(x) <- "integer"
  > 
  > # To check dimnames attribute
  > dimnames <- list(letters[1:6], LETTERS[1:6])
  > 
  > # Test with and without dimnames on x
  > for (setDimnames in c(TRUE, FALSE)) {
  +   if (setDimnames) dimnames(x) <- dimnames
  +   else dimnames(x) <- NULL
  +   for (rows in index_cases) {
  +     for (cols in index_cases) {
  +       # Check names attribute
  +       for (useNames in c(NA, TRUE, FALSE)) {
  +         validateIndicesTestMatrix(x, rows, cols,
  +                                   ftest = rowCumprods, fsure = rowCumprods_R, useNames = useNames)
  +         validateIndicesTestMatrix(x, rows, cols,
  +                                   ftest = function(x, rows, cols, ..., useNames) {
  +           t(colCumprods(t(x), rows = cols, cols = rows, useNames = useNames))
  +         }, fsure = rowCumprods_R, useNames = useNames)
  +       }
  +     }
  +   }
  + }
  Error in validateIndicesTestMatrix(x, rows, cols, ftest = rowCumprods,  : 
    actual and expect are not equal:
    Attributes: < Length mismatch: comparison on first 1 components >
  Calls: validateIndicesTestMatrix -> stopifnot
  Execution halted
Running the tests in ‘tests/rowCumsums.R’ failed.
Complete output:
  > library("matrixStats")
  > 
  > rowCumsums_R <- function(x, ..., useNames = NA) {
  +   suppressWarnings({
  +     y <- t(apply(x, MARGIN = 1L, FUN = cumsum))
  +   })
  +   
  +   # Preserve dimnames attribute?
  +   dim(y) <- dim(x)
  +   if (isTRUE(useNames)) {
  +     dimnames <- dimnames(x)
  +     if (!is.null(dimnames)) dimnames(y) <- dimnames      
  +   }
  +   
  +   y
  + }
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # With and without some NAs
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > dimnames <- list(letters[1:10], LETTERS[1:5]) # to check dimnames attribute
  > for (mode in c("logical", "integer", "double")) {
  +   for (add_na in c(FALSE, TRUE)) {
  +     cat("add_na = ", add_na, "\n", sep = "")
  + 
  +     x <- matrix(1:50, nrow = 10L, ncol = 5L)
  +     if (add_na) {
  +       x[3:7, c(2, 4)] <- NA_real_
  +     }
  +     cat("mode: ", mode, "\n", sep = "")
  +     storage.mode(x) <- mode
  +     str(x)
  +     
  +     # Test with and without dimnames on x
  +     for (setDimnames in c(TRUE, FALSE)) {
  +       if (setDimnames) dimnames(x) <- dimnames
  +       else dimnames(x) <- NULL    
  +       # Check names attribute
  +       for (useNames in c(NA, TRUE, FALSE)) {
  +         # Row/column ranges
  +         r0 <- rowCumsums_R(x, useNames = useNames)
  +         r1 <- rowCumsums(x, useNames = useNames)
  +         r2 <- t(colCumsums(t(x), useNames = useNames))
  +         stopifnot(all.equal(r1, r2))
  +         stopifnot(all.equal(r1, r0))
  +         stopifnot(all.equal(r2, r0))
  +       } # for (useNames ...)
  +     } # for (setDimnames ...)
  +   } # for (add_na ...)
  + }
  add_na = FALSE
  mode: logical
   logi [1:10, 1:5] TRUE TRUE TRUE TRUE TRUE TRUE ...
  Error: r1 and r0 are not equal:
    Attributes: < Length mismatch: comparison on first 1 components >
  In addition: Warning messages:
  1: useNames = NA is deprecated. Instead, specify either useNames = TRUE or useNames = TRUE. 
  2: useNames = NA is deprecated. Instead, specify either useNames = TRUE or useNames = TRUE. 
  Execution halted
Running the tests in ‘tests/rowCumsums_subset.R’ failed.
Complete output:
  > library("matrixStats")
  > 
  > rowCumsums_R <- function(x, ..., useNames = NA) {
  +   suppressWarnings({
  +     y <- t(apply(x, MARGIN = 1L, FUN = cumsum))
  +   })
  +   
  +   # Preserve dimnames attribute?
  +   dim(y) <- dim(x)
  +   if (isTRUE(useNames)) {
  +     dimnames <- dimnames(x)
  +     if (!is.null(dimnames)) dimnames(y) <- dimnames      
  +   }
  + 
  +   y
  + }
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # Subsetted tests
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > source("utils/validateIndicesFramework.R")
  > x <- matrix(runif(6 * 6, min = -3, max = 3), nrow = 6, ncol = 6)
  > storage.mode(x) <- "integer"
  > 
  > # To check dimnames attribute
  > dimnames <- list(letters[1:6], LETTERS[1:6])
  > 
  > # Test with and without dimnames on x
  > for (setDimnames in c(TRUE, FALSE)) {
  +   if (setDimnames) dimnames(x) <- dimnames
  +   else dimnames(x) <- NULL
  +   for (rows in index_cases) {
  +     for (cols in index_cases) {
  +       # Check names attribute
  +       for (useNames in c(NA, TRUE, FALSE)) {
  +         validateIndicesTestMatrix(x, rows, cols,
  +                                   ftest = rowCumsums, fsure = rowCumsums_R, useNames = useNames)
  +         validateIndicesTestMatrix(x, rows, cols,
  +                                   ftest = function(x, rows, cols, ..., useNames) {
  +           t(colCumsums(t(x), rows = cols, cols = rows, useNames = useNames))
  +         }, fsure = rowCumsums_R, useNames = useNames)
  +       }
  +     }
  +   }
  + }
  Error in validateIndicesTestMatrix(x, rows, cols, ftest = rowCumsums,  : 
    actual and expect are not equal:
    Attributes: < Length mismatch: comparison on first 1 components >
  Calls: validateIndicesTestMatrix -> stopifnot
  Execution halted
Running the tests in ‘tests/rowIQRs.R’ failed.
Complete output:
  > library("matrixStats")
  > 
  > rowIQRs_R <- function(x, na.rm = FALSE, ..., useNames = NA) {
  +   quantile_na <- function(x, ..., na.rm = FALSE) {
  +     if (!na.rm && anyMissing(x))
  +       return(c(NA_real_, NA_real_))
  +     quantile(x, ..., na.rm = na.rm)
  +   }
  +   q <- apply(x, MARGIN = 1L, FUN = quantile_na,
  +              probs = c(0.25, 0.75), na.rm = na.rm)
  +   rownames(q) <- NULL # Not needed anymore
  +   
  +   # Preserve names attribute
  +   dim(q) <- c(2L, nrow(x))
  +   names <- rownames(x)
  +   if (isTRUE(useNames) && !is.null(names)) colnames(q) <- names
  +   
  +   q[2L, , drop = TRUE] - q[1L, , drop = TRUE]
  + }
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # Test with multiple quantiles
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > for (mode in c("integer", "double")) {
  +   cat("mode: ", mode, "\n", sep = "")
  +   x <- matrix(1:100 + 0.1, nrow = 10, ncol = 10)
  +   storage.mode(x) <- mode
  +   str(x)
  +   
  +   # To check names attribute
  +   dimnames <- list(letters[1:10], LETTERS[1:10])
  + 
  +   for (add_na in c(FALSE, TRUE)) {
  +     if (add_na) {
  +       x[3:5, 6:9] <- NA
  +     }
  +     # Test with and without dimnames on x
  +     for (setDimnames in c(TRUE, FALSE)) {
  +       if (setDimnames) dimnames(x) <- dimnames
  +       else dimnames(x) <- NULL
  +       for (na.rm in c(FALSE, TRUE)) {
  +         # Check names attribute
  +         for (useNames in c(NA, TRUE, FALSE)) {
  +           probs <- c(0, 0.5, 1)
  +           q0 <- rowIQRs_R(x, na.rm = na.rm, useNames = useNames)
  +           print(q0)
  +           q1 <- rowIQRs(x, na.rm = na.rm, useNames = useNames)
  +           print(q1)
  +           stopifnot(all.equal(q1, q0))
  +           q2 <- colIQRs(t(x), na.rm = na.rm, useNames = useNames)
  +           stopifnot(all.equal(q2, q0))
  +           
  +           q <- iqr(x[3, ], na.rm = na.rm)
  +           print(q)
  +         } # for (useNames ...)
  +       } # for (na.rm ...)
  +     } # for (setDimnames ...)
  +   } # for (add_na ...)
  + } # for (mode ...)
  mode: integer
   int [1:10, 1:10] 1 2 3 4 5 6 7 8 9 10 ...
   a  b  c  d  e  f  g  h  i  j 
  45 45 45 45 45 45 45 45 45 45 
   [1] 45 45 45 45 45 45 45 45 45 45
  Error: q1 and q0 are not equal:
    names for current but not for target
  In addition: Warning messages:
  1: useNames = NA is deprecated. Instead, specify either useNames = TRUE or useNames = TRUE. 
  2: useNames = NA is deprecated. Instead, specify either useNames = TRUE or useNames = TRUE. 
  Execution halted
Running the tests in ‘tests/rowIQRs_subset.R’ failed.
Complete output:
  > library("matrixStats")
  > 
  > rowIQRs_R <- function(x, na.rm = FALSE, ..., useNames = NA) {
  +   quantile_na <- function(x, ..., na.rm = FALSE) {
  +     if (!na.rm && anyMissing(x))
  +       return(c(NA_real_, NA_real_))
  +     quantile(x, ..., na.rm = na.rm)
  +   }
  +   q <- apply(x, MARGIN = 1L, FUN = quantile_na,
  +              probs = c(0.25, 0.75), na.rm = na.rm)
  +   rownames(q) <- NULL # Not needed anymore
  +   
  +   # Preserve names attribute
  +   dim(q) <- c(2L, nrow(x))
  +   names <- rownames(x)
  +   if (isTRUE(useNames) && !is.null(names)) colnames(q) <- names
  +   
  +   q[2L, , drop = TRUE] - q[1L, , drop = TRUE]
  + }
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # Subsetted tests
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > source("utils/validateIndicesFramework.R")
  > x <- runif(6, min = -6, max = 6)
  > for (idxs in index_cases) {
  +   for (na.rm in c(TRUE, FALSE)) {
  +     validateIndicesTestVector(x, idxs, ftest = iqr, fsure = function(x, na.rm) {
  +       dim(x) <- c(1L, length(x))
  +       rowIQRs_R(x, na.rm = na.rm)
  +     }, na.rm = na.rm)
  +   }
  + }
  > 
  > x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6)
  > 
  > # To check names attribute
  > dimnames <- list(letters[1:6], LETTERS[1:6])
  > 
  > # Test with and without dimnames on x
  > for (setDimnames in c(TRUE, FALSE)) {
  +   if (setDimnames) dimnames(x) <- dimnames
  +   else dimnames(x) <- NULL
  +   
  +   count <- 0L
  +   for (rows in index_cases) {
  +     for (cols in index_cases) {
  +       count <- count + 1L
  +       na.rm <- c(TRUE, FALSE)[count %% 2 + 1]
  +       useNames <- c(NA, TRUE, FALSE)[count %% 3 + 1]
  +       
  +       validateIndicesTestMatrix(x, rows, cols,
  +                                 ftest = rowIQRs, fsure = rowIQRs_R,
  +                                 na.rm = na.rm, useNames = useNames)
  +       validateIndicesTestMatrix(x, rows, cols,
  +                                 fcoltest = colIQRs, fsure = rowIQRs_R,
  +                                 na.rm = na.rm, useNames = useNames)
  +     }
  +   }
  + }
  Error in validateIndicesTestMatrix(x, rows, cols, ftest = rowIQRs, fsure = rowIQRs_R,  : 
    actual and expect are not equal:
    names for current but not for target
  Calls: validateIndicesTestMatrix -> stopifnot
  Execution halted
Running the tests in ‘tests/rowRanks.R’ failed.
Complete output:
  > library("matrixStats")
  > 
  > dense_rank <- function(x) match(x, table = sort(unique(x)))
  > 
  > rowRanks_R <- function(x, ties.method, ..., useNames = NA) {
  +   if (ties.method == "dense") {
  +     res <- t(apply(x, MARGIN = 1L, FUN = dense_rank))
  +   } else {
  +     res <- t(apply(x, MARGIN = 1L, FUN = rank, na.last = "keep", ties.method = ties.method))
  +   }
  +   
  +   # Preserve dimnames attribute?
  +   dim(res) <- dim(x)
  +   dimnames <- dimnames(x)
  +   if (isTRUE(useNames) && !is.null(dimnames)) dimnames(res) <- dimnames
  +   
  +   res
  + }
  > 
  > colRanks_R <- function(x, ties.method, preserveShape = FALSE, ..., useNames = NA) {
  +   if (ties.method == "dense") {
  +     res <- t(apply(x, MARGIN = 2L, FUN = dense_rank))
  +   } else {
  +     res <- t(apply(x, MARGIN = 2L, FUN = rank, na.last = "keep", ties.method = ties.method))
  +   }
  +   
  +   # Preserve dimnames attribute?
  +   tx <- t(x)
  +   dim(res) <- dim(tx)
  +   dimnames <- dimnames(tx)
  +   if (isTRUE(useNames) && !is.null(dimnames)) dimnames(res) <- dimnames
  +   
  +   if (preserveShape) res <- t(res)
  +   res
  + }
  > 
  > set.seed(1)
  > 
  > cat("Consistency checks:\n")
  Consistency checks:
  > xs <- vector("list", length = 4L)
  > for (kk in 1:4) {
  +   
  +   # Simulate data in a matrix of any shape
  +   dim <- sample(40:80, size = 2L)
  +   n <- prod(dim)
  +   x <- rnorm(n, sd = 10)
  +   dim(x) <- dim
  +   
  +   # Add NAs?
  +   if ((kk %% 4) %in% c(3, 0)) {
  +     cat("Adding NAs\n")
  +     nna <- sample(n, size = 1L)
  +     x[sample(length(x), size = nna)] <- NA_real_
  +   }
  +   
  +   # Integer or double?
  +   if ((kk %% 4) %in% c(2, 0)) {
  +     cat("Coercing to integers\n")
  +     storage.mode(x) <- "integer"
  +   }
  + 
  +   xs[[kk]] <- x
  + } # for (kk ...)
  Coercing to integers
  Adding NAs
  Adding NAs
  Coercing to integers
  > str(xs)
  List of 4
   $ : num [1:43, 1:78] 13.3 12.72 4.15 -15.4 -9.29 ...
   $ : int [1:46, 1:61] 2 11 -16 -5 19 5 26 -13 1 -9 ...
   $ : num [1:42, 1:47] NA -22.3 NA NA NA ...
   $ : int [1:42, 1:78] NA NA NA NA NA NA NA NA NA NA ...
  > 
  > for (kk in 1:4) {
  +   cat("Random test #", kk, "\n", sep = "")
  +   x <- xs[[kk]]
  +   tx <- t(x)
  +   
  +   for (ties in c("max", "min", "average", "first", "last", "dense")) {
  +     cat(sprintf("ties.method = %s\n", ties))
  +     # rowRanks():
  +     y1 <- matrixStats::rowRanks(x, ties.method = ties)
  +     if (ties != "last" || getRversion() >= "3.3.0") {
  +       y2 <- rowRanks_R(x, ties.method = ties)
  +       stopifnot(identical(y1, y2))
  +     }
  +     
  +     y3 <- matrixStats::colRanks(tx, ties.method = ties)
  +     stopifnot(identical(y1, y3))
  +     
  +     # colRanks():
  +     y1 <- matrixStats::colRanks(x, ties.method = ties)
  +     if (ties != "last" || getRversion() >= "3.3.0") {
  +       y2 <- colRanks_R(x, ties.method = ties)
  +       stopifnot(identical(y1, y2))
  +     }
  +     
  +     y3 <- matrixStats::rowRanks(tx, ties.method = ties)
  +     stopifnot(identical(y1, y3))
  +   }
  + } # for (kk ...)
  Random test #1
  ties.method = max
  ties.method = min
  ties.method = average
  ties.method = first
  ties.method = last
  ties.method = dense
  Random test #2
  ties.method = max
  ties.method = min
  ties.method = average
  ties.method = first
  ties.method = last
  ties.method = dense
  Random test #3
  ties.method = max
  ties.method = min
  ties.method = average
  ties.method = first
  ties.method = last
  ties.method = dense
  Random test #4
  ties.method = max
  ties.method = min
  ties.method = average
  ties.method = first
  ties.method = last
  ties.method = dense
  > 
  > # Note, below we know ties.method %in% c("min", "max", "average") is correct
  > 
  > cat("Consistency checks for random:\n")
  Consistency checks for random:
  > tolerance <- 0.1
  > nsamples <- 10000
  > for (kk in 1:4) {
  +   cat("Random test #", kk, "\n", sep = "")
  +   x <- xs[[kk]]
  +   tx <- t(x)
  + 
  +   for (ties in c("random")) {
  +     cat(sprintf("ties.method = %s\n", ties))
  +     
  +     ## rowRanks():
  +     y0 <- rowRanks_R(x, ties.method = ties)
  +     y1 <- matrixStats::rowRanks(x, ties.method = ties)
  +     
  +     ## Assert symmetric rank differences
  +     d <- y1 - y0
  +     stopifnot(all(rowSums(d) == 0, na.rm = TRUE))
  +     
  +     ## Assert within [min, max]
  +     y2min <- matrixStats::rowRanks(x, ties.method = "min")
  +     y2max <- matrixStats::rowRanks(x, ties.method = "max")
  +     stopifnot(all(y1 >= y2min, na.rm = TRUE) && all(y1 <= y2max, na.rm = TRUE))
  +     ## Assert near average
  +     y1list <- replicate(nsamples, matrixStats::rowRanks(x, ties.method = ties), simplify = FALSE)
  +     y1mean <- Reduce(`+`, y1list) / nsamples
  +     y2avg <- matrixStats::rowRanks(x, ties.method = "average")
  +     stopifnot(all(abs(y1mean - y2avg) < tolerance, na.rm = TRUE))
  + 
  +     ## colRanks():
  +     y0 <- colRanks_R(x, ties.method = ties)
  +     y1 <- matrixStats::colRanks(x, ties.method = ties)
  + 
  +     ## Assert symmetric rank differences
  +     d <- y1 - y0
  +     stopifnot(all(rowSums(d) == 0, na.rm = TRUE))
  + 
  +     ## Assert within [min, max]
  +     y2min <- matrixStats::colRanks(x, ties.method = "min")
  +     y2max <- matrixStats::colRanks(x, ties.method = "max")
  +     stopifnot(all(y1 >= y2min, na.rm = TRUE) && all(y1 <= y2max, na.rm = TRUE))
  +     y1list <- replicate(nsamples, matrixStats::colRanks(x, ties.method = ties), simplify = FALSE)
  +     y1mean <- Reduce(`+`, y1list) / nsamples
  +     ## Assert near average
  +     y2avg <- matrixStats::colRanks(x, ties.method = "average")
  +     stopifnot(all(abs(y1mean - y2avg) < tolerance, na.rm = TRUE))
  +   }
  + } # for (kk ...)
  Random test #1
  ties.method = random
  Random test #2
  ties.method = random
  Random test #3
  ties.method = random
  Random test #4
  ties.method = random
  > 
  > 
  > ## Exception handling
  > x <- matrix(1:12, nrow = 3L, ncol = 4L)
  > y <- try(rowRanks(x, ties.method = "unknown"), silent = TRUE)
  > stopifnot(inherits(y, "try-error"))
  > 
  > y <- try(colRanks(x, ties.method = "unknown"), silent = TRUE)
  > stopifnot(inherits(y, "try-error"))
  > 
  > dimnames <- list(letters[1:3], LETTERS[1:4])
  > for (mode in c("integer", "double")){
  +   storage.mode(x) <- mode
  +   # Test with and without dimnames on x
  +   for (setDimnames in c(TRUE, FALSE)) {
  +     if (setDimnames) dimnames(x) <- dimnames
  +     else dimnames(x) <- NULL
  +     # Check names attribute
  +     for (useNames in c(NA, TRUE, FALSE)) {
  +       for (ties in c("max", "min", "average", "first", "last", "dense", "random")) {
  +         cat(sprintf("ties.method = %s\n", ties))
  +         # rowRanks():
  +         y1 <- matrixStats::rowRanks(x, ties.method = ties, useNames = useNames)
  +         if (ties != "last" || getRversion() >= "3.3.0") {
  +           y2 <- rowRanks_R(x, ties.method = ties, useNames = useNames)
  +           stopifnot(identical(y1, y2))
  +         }
  +         
  +         y3 <- matrixStats::colRanks(t(x), ties.method = ties, useNames = useNames)
  +         stopifnot(identical(y1, y3))
  +         
  +         # colRanks():
  +         y1 <- matrixStats::colRanks(x, ties.method = ties, useNames = useNames)
  +         if (ties != "last" || getRversion() >= "3.3.0") {
  +           y2 <- colRanks_R(x, ties.method = ties, useNames = useNames)
  +           stopifnot(identical(y1, y2))
  +         }
  +         
  +         y3 <- matrixStats::rowRanks(t(x), ties.method = ties, useNames = useNames)
  +         stopifnot(identical(y1, y3))
  +         
  +         # Check preserveShape
  +         y1 <- matrixStats::colRanks(x, ties.method = ties, preserveShape = TRUE, useNames = useNames)
  +         if (ties != "last" || getRversion() >= "3.3.0") {
  +           y2 <- colRanks_R(x, ties.method = ties, preserveShape = TRUE, useNames = useNames)
  +           stopifnot(identical(y1, y2))
  +         }
  +       }
  +     }
  +   }
  + }
  ties.method = max
  Error: identical(y1, y2) is not TRUE
  In addition: Warning message:
  useNames = NA is deprecated. Instead, specify either useNames = TRUE or useNames = TRUE. 
  Execution halted
Running the tests in ‘tests/rowRanks_subset.R’ failed.
Complete output:
  > library("matrixStats")
  > 
  > rowRanks_R <- function(x, ties.method = "average", ..., useNames = NA) {
  +   ans <- t(apply(x, MARGIN = 1L, FUN = rank, na.last = "keep",
  +                  ties.method = ties.method))
  +   
  +   # Preserve dimnames attribute?
  +   dim(ans) <- dim(x)
  +   dimnames <- dimnames(x)
  +   if (isTRUE(useNames) && !is.null(dimnames)) dimnames(ans) <- dimnames
  + 
  +   ans
  + }
  > 
  > colRanks_R <- function(x, ties.method, preserveShape = FALSE, ..., useNames = NA) {
  +   ans <- t(apply(x, MARGIN = 2L, FUN = rank, na.last = "keep", ties.method = ties.method))
  +   
  +   # Preserve dimnames attribute?
  +   tx <- t(x)
  +   dim(ans) <- dim(tx)
  +   dimnames <- dimnames(tx)
  +   if (isTRUE(useNames) && !is.null(dimnames)) dimnames(ans) <- dimnames
  +   
  +   if (preserveShape) ans <- t(ans)
  +   ans
  + }
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # Subsetted tests
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > source("utils/validateIndicesFramework.R")
  > x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6)
  > storage.mode(x) <- "integer"
  > 
  > # To check dimnames attribute
  > dimnames <- list(letters[1:6], LETTERS[1:6])
  > 
  > colRanks_R_t <- function(x, rows, cols, ..., useNames = NA) {
  +   t(colRanks(t(x), rows = cols, cols = rows, preserveShape = TRUE, ..., useNames = useNames))
  + }
  > 
  > # Test with and without dimnames on x
  > for (setDimnames in c(TRUE, FALSE)) {
  +   if (setDimnames) dimnames(x) <- dimnames
  +   else dimnames(x) <- NULL
  + 
  +   count <- 0L
  +   for (rows in index_cases) {
  +     for (cols in index_cases) {
  +       count <- count + 1L
  +       na.rm <- c(TRUE, FALSE)[count %% 2 + 1]
  +       useNames <- c(NA, TRUE, FALSE)[count %% 3 + 1]
  + 
  +       validateIndicesTestMatrix(x, rows, cols,
  +                                 ftest = rowRanks, fsure = rowRanks_R,
  +                                 ties.method = "average", useNames = useNames)
  +       
  +       validateIndicesTestMatrix(x, rows, cols,
  +                                 ftest = colRanks_R_t, fsure = rowRanks_R,
  +                                 ties.method = "average", useNames = useNames)
  +       
  +       for (perserveShape in c(TRUE, FALSE)) {
  +         validateIndicesTestMatrix(x, rows, cols,
  +                                   ftest = colRanks, fsure = colRanks_R,
  +                                   ties.method = "average", perserveShape = perserveShape,
  +                                   useNames = useNames)          
  +       }
  +     }
  +   }
  + }
  Error in validateIndicesTestMatrix(x, rows, cols, ftest = rowRanks, fsure = rowRanks_R,  : 
    actual and expect are not equal:
    Attributes: < Length mismatch: comparison on first 1 components >
  Calls: validateIndicesTestMatrix -> stopifnot
  Execution halted