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 @@ -70,6 +70,8 @@

15. `as.IDate()` and `as.ITime()` now preserve names, matching base `as.Date()` behavior, [#7252](https://github.com/Rdatatable/data.table/issues/7252). Thanks @DavisVaughan for the report and @venom1204 for the PR.

16. `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).
Expand Down
2 changes: 1 addition & 1 deletion R/cedta.R
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down
37 changes: 21 additions & 16 deletions inst/tests/other.Rraw
Original file line number Diff line number Diff line change
@@ -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")
Comment thread
ben-schwen marked this conversation as resolved.
# 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
Expand All @@ -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)) {
Expand Down Expand Up @@ -56,13 +56,11 @@ 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
test(1.1, ggplot(DT, aes(b,f)) + geom_point(), check_value=FALSE) # update as described in #3047
test(1.2, DT[, ggplot(.SD, aes(b,f)) + geom_point(), by=list(grp %% 2L)], check_value=FALSE) # %%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, ggplot(DT) + geom_hex(aes(b, f)) + facet_wrap(~grp), check_value=FALSE)
}
# 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",
Expand All @@ -74,8 +72,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"]]) {
Expand Down Expand Up @@ -166,10 +168,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"]]) {
Expand Down Expand Up @@ -197,7 +200,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) {
Expand Down
10 changes: 5 additions & 5 deletions inst/tests/tests.Rraw
Original file line number Diff line number Diff line change
Expand Up @@ -21606,7 +21606,7 @@ xenv$N = list(a=1:5)
xenv$DF = data.frame(a = 1:2)
xenv$DF$b = data.table(c = 3:4, d = 5:6)
test(2366.1,
tables(env=xenv, depth=1L, index=TRUE)[, .(NAME, NROW, NCOL, INDICES, KEY)],
tables(env=xenv, depth=1L, index=TRUE, silent=TRUE)[, .(NAME, NROW, NCOL, INDICES, KEY)],
data.table(
NAME = c("DF$b", "DT", "L[[1]]", "L[[2]]", "M$b"),
NROW = c(2L, 1L, 3L, 4L, 3L),
Expand All @@ -21616,20 +21616,20 @@ test(2366.1,
))
setindex(xenv$M$b, b)
test(2366.2,
tables(env=xenv, depth=1L, index=TRUE)[, .(INDICES, KEY)],
tables(env=xenv, depth=1L, index=TRUE, silent=TRUE)[, .(INDICES, KEY)],
data.table(INDICES = list(NULL, NULL, NULL, NULL, "b"), KEY = list(NULL, NULL, NULL, NULL, NULL)))
setkey(xenv$M$b, a)
test(2366.3,
tables(env=xenv, depth=1L, index=TRUE)[, .(INDICES, KEY)],
tables(env=xenv, depth=1L, index=TRUE, silent=TRUE)[, .(INDICES, KEY)],
data.table(INDICES = list(NULL, NULL, NULL, NULL, "b"), KEY = list(NULL, NULL, NULL, NULL, "a")))
# test for depth>1L
test(2366.4, tables(env=xenv, depth=2L), error="depth>1L is not implemented yet")
rm(xenv)

# no data.table test
xenv_empty = new.env()
test(2366.5, tables(env=xenv_empty, depth=1L), invisible(data.table(NULL)))
test(2366.6, tables(env=xenv_empty), invisible(data.table(NULL)))
test(2366.5, tables(env=xenv_empty, depth=1L, silent=TRUE), invisible(data.table(NULL)))
test(2366.6, tables(env=xenv_empty, silent=TRUE), invisible(data.table(NULL)))
rm(xenv_empty)

# fread supports connections #561
Expand Down
Loading