Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move tests + add options #6354

Merged
merged 1 commit into from
Aug 5, 2024
Merged
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
24 changes: 4 additions & 20 deletions inst/tests/nafill.Rraw
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ if (exists("test.data.table", .GlobalEnv, inherits=FALSE)) {
}

sugg = c(
"bit64",
"nanotime"
"bit64"
)
for (s in sugg) {
assign(paste0("test_",s), loaded<-suppressWarnings(suppressMessages(
Expand Down Expand Up @@ -84,13 +83,7 @@ if (test_bit64) {
test(1.76, nafill(as.integer64(c(1,2,NA,4)), fill=NA_real_), as.integer64(c(1:2,NA,4L)))
test(1.77, nafill(as.integer64(c(1,2,NA,4)), fill=NA), as.integer64(c(1:2,NA,4L)))
}
if (test_nanotime) {
l = list(a=nanotime(c(1:2,NA,4:5)), b=nanotime(c(NA,2L,NA,4L,NA)))
test(1.91, lapply(nafill(l, "locf"), as.character), lapply(list(a=nanotime(c(1:2,2L,4:5)), b=nanotime(c(NA,2L,2L,4L,4L))), as.character))
test(1.92, lapply(nafill(l, "nocb"), as.character), lapply(list(a=nanotime(c(1:2,4L,4:5)), b=nanotime(c(2L,2L,4L,4L,NA))), as.character))
test(1.93, lapply(nafill(l, fill=0), as.character), lapply(list(a=nanotime(c(1:2,0L,4:5)), b=nanotime(c(0L,2L,0L,4L,0L))), as.character))
test(1.94, lapply(nafill(l, fill=nanotime(0)), as.character), lapply(list(a=nanotime(c(1:2,0L,4:5)), b=nanotime(c(0L,2L,0L,4L,0L))), as.character))
}
# 1.91 tested nanotime moved to other.Rraw 27.11, #6139

# setnafill
dt = data.table(V1=1:10, V2=10:1, V3=1:10/2)
Expand Down Expand Up @@ -307,16 +300,8 @@ if (test_bit64) {
options(datatable.verbose=2L)
test(10.89, coerceAs(-2147483649, x), as.integer64(-2147483649), output="double[numeric] into double[integer64]")
}
if (test_nanotime) {
x = nanotime(1L)
test(10.91, coerceAs(x, 1), 1, output="double[nanotime] into double[numeric]")
test(10.92, coerceAs(x, 1L), 1L, output="double[nanotime] into integer[integer]")
test(10.93, substring(coerceAs(x, "1"),1,11) %in% c("1","1970-01-01T"), output="double[nanotime] into character[character]")
# ^ https://github.com/eddelbuettel/nanotime/issues/92; %in% so as not to break if nanotime adds as.character method
test(10.94, coerceAs(1, x), x, output="double[numeric] into double[nanotime]")
test(10.95, coerceAs(1L, x), x, output="integer[integer] into double[nanotime]")
test(10.96, coerceAs("1", x), x, output="character[character] into double[nanotime]", warning="Coercing.*character")
}
# 10.91 tested nanotime moved to other.Rraw 27.21, #6139

options(datatable.verbose=FALSE)
test(11.01, coerceAs(list(a=1), 1), error="is not atomic")
test(11.02, coerceAs(1, list(a=1)), list(1))
Expand All @@ -338,7 +323,6 @@ test(11.09, coerceAs(1L, a), error="must not be matrix or array")
## POSIXct
## IDate
## ITime
## nanotime

# related to !is.integer(verbose)
test(99.1, data.table(a=1,b=2)[1,1, verbose=1], error="verbose must be logical or integer")
Expand Down
17 changes: 17 additions & 0 deletions inst/tests/other.Rraw
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,23 @@ if (loaded[["nanotime"]]) {
y[, b := NULL]
test(27.03, rbind(x,y, fill = TRUE), data.table(a = c(1L, 2L), b=as.nanotime(c(0, NA))))
test(27.04, rbind(y,x, fill = TRUE), data.table(a = c(2L, 1L), b=as.nanotime(c(NA, 0))))

# Was 1.91-1.94 in nafill.Rraw, #6139
l = list(a=nanotime(c(1:2,NA,4:5)), b=nanotime(c(NA,2L,NA,4L,NA)))
test(27.11, lapply(nafill(l, "locf"), as.character), lapply(list(a=nanotime(c(1:2,2L,4:5)), b=nanotime(c(NA,2L,2L,4L,4L))), as.character))
test(27.12, lapply(nafill(l, "nocb"), as.character), lapply(list(a=nanotime(c(1:2,4L,4:5)), b=nanotime(c(2L,2L,4L,4L,NA))), as.character))
test(27.13, lapply(nafill(l, fill=0), as.character), lapply(list(a=nanotime(c(1:2,0L,4:5)), b=nanotime(c(0L,2L,0L,4L,0L))), as.character))
test(27.14, lapply(nafill(l, fill=nanotime(0)), as.character), lapply(list(a=nanotime(c(1:2,0L,4:5)), b=nanotime(c(0L,2L,0L,4L,0L))), as.character))

# coerceAs verbose. Was 10.91-10.96 in nafill.Rraw, #6139
x = nanotime(1L)
test(27.21, options=c(datatable.verbose=2L), coerceAs(x, 1), 1, output="double[nanotime] into double[numeric]")
test(27.22, options=c(datatable.verbose=2L), coerceAs(x, 1L), 1L, output="double[nanotime] into integer[integer]")
test(27.23, options=c(datatable.verbose=2L), substring(coerceAs(x, "1"),1,11) %in% c("1","1970-01-01T"), output="double[nanotime] into character[character]")
# ^ https://github.com/eddelbuettel/nanotime/issues/92; %in% so as not to break if nanotime adds as.character method
test(27.24, options=c(datatable.verbose=2L), coerceAs(1, x), x, output="double[numeric] into double[nanotime]")
test(27.25, options=c(datatable.verbose=2L), coerceAs(1L, x), x, output="integer[integer] into double[nanotime]")
test(27.26, options=c(datatable.verbose=2L), coerceAs("1", x), x, output="character[character] into double[nanotime]", warning="Coercing.*character")
}

# that plot works; moved from tests.Rraw 167 to here to save ram of loading graphics package and possible screen device issues on overloaded servers, #5517
Expand Down
Loading