diff --git a/NEWS.md b/NEWS.md index 025e9a578..b4aef7682 100644 --- a/NEWS.md +++ b/NEWS.md @@ -62,6 +62,8 @@ 13. `rbindlist()` (and therefore the `rbind()` method for `data.table`s) no longer raises an error upon encountering more than approximately 50000 columns in a list entry, [#7793](https://github.com/Rdatatable/data.table/issues/7793). The bug was introduced in `data.table` version 1.18.2.1. Thanks to @rickhelmus for the report and @aitap for the fix. +14. `example(local=TRUE)` where the example uses `[.data.table` works again (e.g. `example(':=', package='data.table', local=TRUE, echo=FALSE)`), [#7833](https://github.com/Rdatatable/data.table/issues/7833) re-fixing [#2972](https://github.com/Rdatatable/data.table/issues/2972). Thanks @michaelChirico for the fix. + ### Notes 1. {data.table} now depends on R 3.5.0 (2018). diff --git a/R/cedta.R b/R/cedta.R index 11e365495..f25a8d23c 100644 --- a/R/cedta.R +++ b/R/cedta.R @@ -64,7 +64,7 @@ cedta.pkgEvalsUserCode = c("gWidgetsWWW","statET","FastRWeb","slidify","rmarkdow if (exists("debugger.look", parent.frame(n+1L))) return(TRUE) # nocov # 'example' for #2972 - if (length(sc) >= 8L && sc[[length(sc) - 7L]] %iscall% 'example') return(TRUE) # nocov + if (length(sc) >= 9L && sc[[length(sc) - 8L]] %iscall% 'example') return(TRUE) # nocov } if (nsname == "base") { diff --git a/inst/tests/other.Rraw b/inst/tests/other.Rraw index 4b8685a60..1232a6c97 100644 --- a/inst/tests/other.Rraw +++ b/inst/tests/other.Rraw @@ -1,9 +1,9 @@ -pkgs = c("DBI", "RSQLite", "bit64", "caret", "dplyr", "gdata", "ggplot2", "hexbin", "knitr", "nanotime", "nlme", "parallel", "plyr", "R.utils", "sf", "vctrs", "xts", "yaml", "zoo") +pkgs = c("DBI", "RSQLite", "bit64", "ggplot2", "caret", "dplyr", "gdata", "hexbin", "knitr", "nanotime", "nlme", "parallel", "plyr", "R.utils", "sf", "vctrs", "zoo", "xts", "yaml") # First expression of this file must be as above: .gitlab-ci.yml uses parse(,n=1L) to read one expression from this file and installs pkgs. # So that these dependencies of other.Rraw are maintained in a single place. +# TODO(R>=3.6.0): use attach.required=FALSE to let us keep pkgs= in alphabetical order (https://stat.ethz.ch/pipermail/r-devel/2026-July/084630.html) # TEST_DATA_TABLE_WITH_OTHER_PACKAGES is off by default so this other.Rraw doesn't run on CRAN. It is run by GLCI, locally in dev, and by -# users running test.data.table("other.Rraw"). -# zoo needs to be before xts for #5101 otherwise xts's dependency zoo gets attached at position 2 if xts is loaded first +# users running test.data.table("other.Rraw"). # Optional Suggest-ed package tests moved from tests.Rraw to here in #5516. Retaining their comments: # "xts", # we have xts methods in R/xts.R @@ -27,7 +27,7 @@ INT = data.table:::INT if (anyDuplicated(pkgs)) stop("Packages defined to be loaded for integration tests in 'inst/tests/other.Rraw' contains duplicates.") f = function(pkg) suppressWarnings(suppressMessages(isTRUE( - library(pkg, character.only=TRUE, logical.return=TRUE, warn.conflicts=FALSE, pos="package:base") # attach at the end for #5101 + library(pkg, character.only=TRUE, logical.return=TRUE, warn.conflicts=FALSE, pos="package:base") # attach at the end for #5101 ))) loaded = sapply(pkgs, f) if (!all(loaded)) { @@ -56,13 +56,12 @@ if (all(c("package:reshape", "package:reshape2") %in% search())) { if (loaded[["ggplot2"]]) { DT = data.table( a=1:5, b=11:50, d=c("A","B","C","D"), f=1:5, grp=1:5 ) - test(1.1, names(print(ggplot(DT,aes(b,f))+geom_point()))[c(1,3)], c("data","scales")) # update as described in #3047 - test(1.2, DT[,print(ggplot(.SD,aes(b,f))+geom_point()),by=list(grp%%2L)],data.table(grp=integer())) # %%2 to reduce time needed for ggplot2 to plot + print_without_error = function(x) !inherits(tryCatch(print(x), error=identity), "error") + test(1.1, print_without_error(ggplot(DT, aes(b,f)) + geom_point())) # update as described in #3047 + test(1.2, DT[, print_without_error(ggplot(.SD, aes(b,f)) + geom_point()), by=list(grp %% 2L)][, all(V1)]) # %%2 to reduce time needed for ggplot2 to plot if (loaded[["hexbin"]]) { # Test reported by C Neff on 11 Oct 2011 - # TODO(r-lib/gtable#94): don't suppressWarnings() here. - x <- suppressWarnings(print(ggplot(DT) + geom_hex(aes(b, f)) + facet_wrap(~grp))) - test(1.3, names(x)[c(1L, 3L)], c("data", "scales")) + test(1.3, print_without_error(ggplot(DT) + geom_hex(aes(b, f)) + facet_wrap(~grp))) } # Test plotting ITime with ggplot2 which seems to require an as.data.frame method for ITime, #1713 datetimes = c("2011 NOV18 09:29:16", "2011 NOV18 10:42:40", "2011 NOV18 23:47:12", @@ -74,8 +73,12 @@ if (loaded[["ggplot2"]]) { # test(1.4, print(DT[,qplot(idate,itime)])$ranges, # message="Don't know how to automatically pick scale for object of type ITime. Defaulting to continuous") - test(1.5, print(DT[,qplot(idate,as.POSIXct(itime,tzone=""))])$ranges, print(qplot(idate,as.POSIXct(itime,tzone=""),data=DT))$ranges) - try(graphics.off(),silent=TRUE) + # qplot() soon to be deleted, unclear how to adapt the test meaningfully after that... + invisible(tryCatch(qplot(), condition=function(.) NULL)) # force deprecation warning + test(1.5, all.equal( + print(DT[, qplot(idate, as.POSIXct(itime, tzone=""))]), + print(qplot(idate, as.POSIXct(itime, tzone=""), data=DT)))) + try(graphics.off(), silent=TRUE) } if (loaded[["plyr"]]) { @@ -166,10 +169,11 @@ if (loaded[["nlme"]]) { if (loaded[["bit64"]]) { # these don't pass UBSAN/USAN because of the overflow, so just here in other.Rraw - test(9.1, as.character((as.integer64(2^62)-1)*2+1), "9223372036854775807") - test(9.2, as.character((as.integer64(2^62)-1)*2+2), NA_character_, warning="integer64 overflow") - test(9.3, as.character(-(as.integer64(2^62)-1)*2-1), "-9223372036854775807") - test(9.4, as.character(-(as.integer64(2^62)-1)*2-2), NA_character_, warning="integer64.*flow") + # Use 'L' to avoid integer64-double math when 'long double' is unavailable. + test(9.1, as.character((as.integer64(2^62)-1L)*2L+1L), "9223372036854775807") + test(9.2, as.character((as.integer64(2^62)-1L)*2L+2L), NA_character_, warning="integer64 overflow") + test(9.3, as.character(-(as.integer64(2^62)-1L)*2L-1L), "-9223372036854775807") + test(9.4, as.character(-(as.integer64(2^62)-1L)*2L-2L), NA_character_, warning="integer64.*flow") } if (loaded[["gdata"]]) { @@ -197,7 +201,9 @@ if (loaded[["knitr"]]) { if (loaded[["parallel"]]) { #1745 and #1727 if (.Platform$OS.type=="windows") { - warning("This test of auto fallback to single threaded mode when data.table is used from package parallel, does not run on Windows because 'mc.cores'>1 is not supported on Windows; i.e., parallel package isn't parallel on Windows, IIUC. Whereas data.table is parallel built-in on Windows for some functions (fwrite/fread/fsort and expanding) using OpenMP.") + cat( + strwrap("This test of auto fallback to single threaded mode when data.table is used from package parallel, does not run on Windows because 'mc.cores'>1 is not supported on Windows; i.e., parallel package isn't parallel on Windows, IIUC. Whereas data.table is parallel built-in on Windows for some functions (fwrite/fread/fsort and expanding) using OpenMP.\n"), + sep="\n") } else { setDTthreads(2) if (getDTthreads()!=2) {