Browse code

Drop matrix attribute in colQuantiles if length(prob) == 1

const-ae authored on 16/10/2020 09:15:21
Showing 2 changed files

... ...
@@ -534,6 +534,8 @@ setMethod("colQuantiles", signature(x = "xgCMatrix"),
534 534
   rownames(mat) <- colnames(x)
535 535
   if(drop && nrow(mat) == 1){
536 536
     mat[1,]
537
+  }else  if(drop && ncol(mat) == 1){
538
+    mat[,1]
537 539
   }else{
538 540
     mat
539 541
   }
... ...
@@ -198,6 +198,7 @@ for(idx in seq_along(matrix_list)){
198 198
   test_that("colQuantiles works", {
199 199
     expect_equal(colQuantiles(sp_mat), matrixStats::colQuantiles(mat))
200 200
     expect_equal(colQuantiles(sp_mat, na.rm=TRUE), matrixStats::colQuantiles(mat, na.rm=TRUE))
201
+    expect_equal(colQuantiles(sp_mat, prob = 0.3, na.rm=TRUE), matrixStats::colQuantiles(mat, prob = 0.3, na.rm=TRUE))
201 202
     expect_equal(colQuantiles(sp_mat, rows = row_subset, cols = col_subset), matrixStats::colQuantiles(mat, rows = row_subset, cols = col_subset))
202 203
 
203 204
     expect_equal(colQuantiles(sp_mat, type = 1L), matrixStats::colQuantiles(mat, type = 1L))