Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #7791 +/- ##
=======================================
Coverage 98.85% 98.85%
=======================================
Files 87 87
Lines 17140 17156 +16
=======================================
+ Hits 16944 16960 +16
Misses 196 196 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Generated via commit e697d45 Download link for the artifact containing the test results: ↓ atime-results.zip
|
| cons_width = getOption("width") | ||
| cols_to_print = widths < cons_width | ||
| not_printed = colnames(toprint)[!cols_to_print] | ||
|
|
| test(2374.10, key(DT[, .(a.1, sum(val)), keyby=.(a, a)]), NULL) | ||
|
|
||
| #6663 Option to print the number of columns | ||
| test(2375.1, {options(datatable.show.ncols=TRUE); DT=as.data.table(iris); capture.output(print(DT))[1L]}, "Number of columns: 5") |
There was a problem hiding this comment.
We have an options parameter in test, so please use it!
Please only use bracket blocks {} when it adds clarity, here it seems more complicated then using setup step.
Also you can set multiple options at once with options.
ben-schwen
left a comment
There was a problem hiding this comment.
There seems to be a problem when trunc.cols and nrow>20
options(width=40, datatable.show.ncols=TRUE)
DT = data.table(a=1:21,b=1:21,c=1:21,d=1:21,e=1:21,f=1:21,g=1:21,h=1:21)
print(DT, trunc.cols=TRUE, class=TRUE)
# Number of columns: 8, of which 3 are not shown: [f <int>, g <int>, h <int>]
# Error in rbind(toprint, matrix(if (quote) old else colnames(toprint), :
# number of columns of matrices must match (see arg 3)| )) | ||
| } | ||
| if (show.ncols && !isTRUE(trunc.cols) && !any(dim(x)==0L)) { | ||
| catf("Number of columns: %d\n", ncol(x)) |
There was a problem hiding this comment.
Maybe use a helper here, similar to trunc_cols_message and dt_width
| cols_to_print = widths < cons_width | ||
| not_printed = colnames(toprint)[!cols_to_print] | ||
| if (show.ncols) { | ||
| n_not_printed = length(not_printed) |
There was a problem hiding this comment.
this seems like a near copy of trunc_cols_message, rework it to use it here
| catf("Number of columns: %d, of which %d %s not shown: %s\n", | ||
| ncol(x), n_not_printed, ngettext(n_not_printed, "is", "are"), | ||
| brackify(paste0(not_printed, classes))) | ||
| trunc.cols = FALSE |
There was a problem hiding this comment.
trunc.cols is now overloaded with multiple tasks. maybe use a separate boolean for this.

closes #6663.
in this pr I
datatable.show.ncolsoption (default FALSE).trunc.cols=TRUEoutput.hi @tdhock @joshhwuu can you please have a look when you get time.
thanks