Skip to content

Commit 556b293

Browse files
committed
update cedta dispatch
1 parent 91a6c43 commit 556b293

File tree

4 files changed

+748
-748
lines changed

4 files changed

+748
-748
lines changed

R/cedta.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ cedta.pkgEvalsUserCode = c("gWidgetsWWW","statET","FastRWeb","slidify","rmarkdow
4848
}
4949

5050
# cedta = Calling Environment Data.Table-Aware
51-
cedta = function(n=2L) {
51+
cedta = function(n=2L, verbose = getOption("datatable.verbose", FALSE)) {
5252
# Calling Environment Data Table Aware
5353
env = parent.frame(n)
5454
if (isTRUEorFALSE(env$.datatable.aware)) { # dtplyr#184, #5654
@@ -72,7 +72,7 @@ cedta = function(n=2L) {
7272
(nsname %chin% cedta.pkgEvalsUserCode && .any_eval_calls_in_stack()) ||
7373
isTRUE(ns$.datatable.aware) || # As of Sep 2018: RCAS, caretEnsemble, dtplyr, rstanarm, rbokeh, CEMiTool, rqdatatable, RImmPort, BPRMeth, rlist
7474
tryCatch("data.table" %chin% get(".Depends",paste("package",nsname,sep=":"),inherits=FALSE),error=function(e)FALSE) # both ns$.Depends and get(.Depends,ns) are not sufficient
75-
if (!ans && getOption("datatable.verbose")) {
75+
if (!ans && verbose) {
7676
# nocov start
7777
catf("cedta decided '%s' wasn't data.table aware. Here is call stack with [[1L]] applied:\n", nsname)
7878
print(sapply(sys.calls(), `[[`, 1L))

R/data.table.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
dim.data.table = function(x)
22
{
3-
if (!cedta()) return(NextMethod()) # nocov
3+
if (!cedta(verbose=FALSE)) return(NextMethod()) # nocov
44
.Call(Cdim, x)
55
}
66

R/print.data.table.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ print.data.table = function(x, topn=getOption("datatable.print.topn"),
7272
setnames(index_dt, print_names)
7373
}
7474
}
75-
n_x = nrow(x)
75+
n_x = dim(x)[1L] # manually dispatch nrow() to avoid dispatching to S3 method
7676
if ((topn*2L+1L)<n_x && (n_x>nrows || !topnmiss)) {
7777
toprint = rbindlist(list(head(x, topn), tail(x, topn)), use.names=FALSE) # no need to match names because head and tail of same x, and #3306
7878
rn = c(seq_len(topn), seq.int(to=n_x, length.out=topn))
@@ -143,7 +143,7 @@ print.data.table = function(x, topn=getOption("datatable.print.topn"),
143143
}
144144
if (col.names == "none")
145145
colnames(toprint) = rep.int("", ncol(toprint))
146-
if (nrow(toprint)>20L && col.names == "auto")
146+
if (NROW(toprint)>20L && col.names == "auto")
147147
# repeat colnames at the bottom if over 20 rows so you don't have to scroll up to see them
148148
# option to shut this off per request of Oleg Bondar on SO, #1482
149149
toprint = rbind(
@@ -271,7 +271,7 @@ dt_width = function(x, nrow, class, row.names, col.names) {
271271
}
272272
# keeps the dim and dimnames attributes
273273
toprint_subset = function(x, cols_to_print) {
274-
if (nrow(x) == 1L){
274+
if (NROW(x) == 1L){
275275
atts = attributes(x)
276276
atts$dim = c(1L, sum(cols_to_print))
277277
atts$dimnames[[2L]] = atts$dimnames[[2L]][cols_to_print]

0 commit comments

Comments
 (0)