Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@

14. Filling columns of class Date with POSIXct (and vice versa) using `shift()` now yields a clear, informative error message specifying the class mismatch, [#5218](https://github.com/Rdatatable/data.table/issues/5218). Thanks @ashbaldry for the report and @ben-schwen for the fix.

15. `dim.data.table` returns now the same as `dim.data.frame` in `data.table`-unaware environments, [#2422](https://github.com/Rdatatable/data.table/issues/2422). Thanks to @akersting for reporting and Benjamin Schwendinger for the fix.

### NOTES

1. The following in-progress deprecations have proceeded:
Expand Down
4 changes: 2 additions & 2 deletions R/cedta.R
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ cedta.pkgEvalsUserCode = c("gWidgetsWWW","statET","FastRWeb","slidify","rmarkdow
}

# cedta = Calling Environment Data.Table-Aware
cedta = function(n=2L) {
cedta = function(n=2L, verbose = getOption("datatable.verbose", FALSE)) {
# Calling Environment Data Table Aware
env = parent.frame(n)
if (isTRUEorFALSE(env$.datatable.aware)) { # dtplyr#184, #5654
Expand All @@ -72,7 +72,7 @@ cedta = function(n=2L) {
(nsname %chin% cedta.pkgEvalsUserCode && .any_eval_calls_in_stack()) ||
isTRUE(ns$.datatable.aware) || # As of Sep 2018: RCAS, caretEnsemble, dtplyr, rstanarm, rbokeh, CEMiTool, rqdatatable, RImmPort, BPRMeth, rlist
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
if (!ans && getOption("datatable.verbose")) {
if (!ans && verbose) {
# nocov start
catf("cedta decided '%s' wasn't data.table aware. Here is call stack with [[1L]] applied:\n", nsname)
print(sapply(sys.calls(), `[[`, 1L))
Expand Down
1 change: 1 addition & 0 deletions R/data.table.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
dim.data.table = function(x)
{
if (!cedta(verbose=FALSE)) return(NextMethod()) # nocov
Copy link
Member

@jangorecki jangorecki Jul 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the exact reason to forcing verbose to F here? Why in this particular method we want to see less?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason is that we call dim in every print statement which are often not cedta

Copy link
Member

@MichaelChirico MichaelChirico Jul 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't that resolved by switching to nrow(x)[1L] in print.data.table?

We could instead call .Call(Cdim, x)[1L] right?


I do see other dim() usage in print.data.table:

if (any(dim(x)==0L)) {

So maybe we want dim_x = .Call(Cdim, x) & proceed from there?

.Call(Cdim, x)
}

Expand Down
2 changes: 1 addition & 1 deletion R/print.data.table.R
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ print.data.table = function(x, topn=getOption("datatable.print.topn"),
setnames(index_dt, print_names)
}
}
n_x = nrow(x)
n_x = dim(x)[1L] # manually dispatch nrow() to avoid dispatching to S3 method
if ((topn*2L+1L)<n_x && (n_x>nrows || !topnmiss)) {
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
rn = c(seq_len(topn), seq.int(to=n_x, length.out=topn))
Expand Down
Loading