Skip to content

Commit 26bd48a

Browse files
committed
Merge branch 'master' of https://github.com/Rdatatable/data.table into issue_2606
2 parents 405d693 + d3252f8 commit 26bd48a

File tree

4 files changed

+26
-8
lines changed

4 files changed

+26
-8
lines changed

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@
7474
7575
12. `print(..., col.names = 'none')` now correctly adapts column widths to the data content, ignoring the original column names and producing a more compact output, [#6882](https://github.com/Rdatatable/data.table/issues/6882). Thanks to @brooksambrose for the report and @venom1204 for the PR.
7676
77+
13. Reference to `.SD` in `...` arguments to `lapply()`, e.g. ``lapply(list_of_tables, `[`, j=.SD[1L])`` is evaluated correctly, [#2982](https://github.com/Rdatatable/data.table/issues/2982). Thanks @franknarf1 for the report and @MichaelChirico for the fix.
78+
7779
### NOTES
7880
7981
1. The following in-progress deprecations have proceeded:

R/cedta.R

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,16 @@ cedta.pkgEvalsUserCode = c("gWidgetsWWW","statET","FastRWeb","slidify","rmarkdow
3939
}
4040
# nocov end
4141

42+
.any_sd_queries_in_stack = function(calls) {
43+
for (ii in length(calls):1) { # nolint: seq_linter. As above.
44+
if (!calls[[ii]] %iscall% "[") next
45+
the_lhs = calls[[ii]][[2L]]
46+
if (!is.name(the_lhs) || the_lhs != ".SD") next
47+
return(TRUE)
48+
}
49+
FALSE
50+
}
51+
4252
# cedta = Calling Environment Data.Table-Aware
4353
cedta = function(n=2L) {
4454
# Calling Environment Data Table Aware
@@ -52,12 +62,15 @@ cedta = function(n=2L) {
5262
return(TRUE)
5363
}
5464
nsname = getNamespaceName(ns)
65+
sc = sys.calls()
5566
ans = nsname=="data.table" ||
5667
"data.table" %chin% names(getNamespaceImports(ns)) || # most common and recommended cases first for speed
5768
(nsname=="utils" &&
5869
(exists("debugger.look", parent.frame(n+1L)) ||
59-
(length(sc<-sys.calls())>=8L && sc[[length(sc)-7L]] %iscall% 'example')) ) || # 'example' for #2972
60-
(nsname=="base" && all(c("FUN", "X") %chin% ls(parent.frame(n)))) || # lapply
70+
(length(sc)>=8L && sc[[length(sc)-7L]] %iscall% 'example')) ) || # 'example' for #2972
71+
(nsname=="base" && # lapply
72+
(all(c("FUN", "X") %chin% ls(parent.frame(n))) ||
73+
.any_sd_queries_in_stack(sc))) ||
6174
(nsname %chin% cedta.pkgEvalsUserCode && .any_eval_calls_in_stack()) ||
6275
nsname %chin% cedta.override ||
6376
isTRUE(ns$.datatable.aware) || # As of Sep 2018: RCAS, caretEnsemble, dtplyr, rstanarm, rbokeh, CEMiTool, rqdatatable, RImmPort, BPRMeth, rlist

R/test.data.table.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ test.data.table = function(script="tests.Rraw", verbose=FALSE, pkg=".", silent=F
197197
tryCatch(error = function(c) warningf("Attempt to subset to %d tests matching '%s' failed, running full suite.", length(keep_test_ids), testPattern), {
198198
new_script = file_lines[c(header_lines, keep_lines)]
199199
parse(text = new_script) # as noted above the static approach is not fool-proof (yet?), so force the script to at least parse before continuing.
200-
fn = tempfile()
200+
fn = setNames(tempfile(), names(fn))
201201
on.exit(unlink(fn), add=TRUE)
202202
catf("Running %d of %d tests matching '%s'\n", length(keep_test_ids), nrow(test_calls), testPattern)
203203
writeLines(new_script, fn)

inst/tests/tests.Rraw

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21427,34 +21427,37 @@ test(2330.7, as.data.table(list(z), keep.rownames=TRUE), data.table(rn=rep("", 3
2142721427
M <- matrix(1:6, nrow=3, dimnames=list(rep("", 3), c("V1", "V2"))) # test of list(M) for empty-rowname'd matrix input
2142821428
test(2330.8, as.data.table(list(M), keep.rownames=TRUE), data.table(rn=rep("", 3), V1=1:3, V2=4:6))
2142921429

21430+
# .SD reference in '...' passed to lapply(FUN=) is recognized as data.table
21431+
test(2331, lapply(list(data.table(a=1:2)), `[`, j=.SD[1L]), list(data.table(a=1L)))
21432+
2143021433
#2606 Recursive tables() naming convention
21431-
test(2331.1, local({
21434+
test(2332.1, local({
2143221435
lst_named = list(inner = data.table(a = 1))
2143321436
lst_unnamed = list(data.table(b = 2))
2143421437
nested = list(l1 = list(l2 = data.table(c = 3)))
2143521438
out = tables(recursive = TRUE)$NAME
2143621439
all(c("lst_named$inner", "lst_unnamed[[1]]", "nested$l1$l2") %in% out)
2143721440
}))
21438-
test(2331.2, local({
21441+
test(2332.2, local({
2143921442
mixed = list(data.table(x = 1), y = data.table(z = 2))
2144021443
out = tables(recursive = TRUE)$NAME
2144121444
all(c("mixed[[1]]", "mixed$y") %in% out)
2144221445
}))
21443-
test(2331.3, local({
21446+
test(2332.3, local({
2144421447
mixed_nested = list(
2144521448
A = list(data.table(p = 1), q = data.table(q = 2)))
2144621449
out = tables(recursive = TRUE)$NAME
2144721450
all(c("mixed_nested$A[[1]]", "mixed_nested$A$q") %in% out)
2144821451
}))
21449-
test(2331.4, local({
21452+
test(2332.4, local({
2145021453
dt <- data.table(val = 42)
2145121454
e <- new.env()
2145221455
e$dt <- dt
2145321456
e$self <- e
2145421457
out = tables(recursive = TRUE, env = e)$NAME
2145521458
identical(out, "dt")
2145621459
}))
21457-
test(2331.5, local({
21460+
test(2332.5, local({
2145821461
cycle <- list()
2145921462
cycle[[1]] <- cycle
2146021463
cycle[[2]] <- list(cycle) # nested cycle

0 commit comments

Comments
 (0)