diff --git a/inst/tests/froll.Rraw b/inst/tests/froll.Rraw index f6a4f96a80..4fe6b8ce8a 100644 --- a/inst/tests/froll.Rraw +++ b/inst/tests/froll.Rraw @@ -303,8 +303,7 @@ expected = list(c(NA, 0.5, 1.5, 1.75, 2, 3), c(NA, NA, 1, 1.75, 1.75, 2.5), c(NA test(6000.066, ans1, expected) test(6000.067, ans2, expected) #### early stopping NAs in leading k obs -options(datatable.verbose=TRUE) -test(6000.0671, frollmean(c(1:2,NA,4:10), 4), c(rep(NA_real_, 6), 5.5, 6.5, 7.5, 8.5), output=c( +test(6000.0671, options = c(datatable.verbose=TRUE), frollmean(c(1:2,NA,4:10), 4), c(rep(NA_real_, 6), 5.5, 6.5, 7.5, 8.5), output=c( "frollfunR: allocating memory for results 1x1", "frollfunR: 1 column.*1 window.*", "frollfunR: 1:", @@ -313,7 +312,7 @@ test(6000.0671, frollmean(c(1:2,NA,4:10), 4), c(rep(NA_real_, 6), 5.5, 6.5, 7.5, "frollmean: processing algo 0 took.*", "frollfunR: processing.*took.*" )) -test(6000.0672, frollmean(c(1:2,NA,4:10), 4, hasNA=FALSE), c(rep(NA_real_, 6), 5.5, 6.5, 7.5, 8.5), output=c( +test(6000.0672, options = c(datatable.verbose=TRUE), frollmean(c(1:2,NA,4:10), 4, hasNA=FALSE), c(rep(NA_real_, 6), 5.5, 6.5, 7.5, 8.5), output=c( "frollfunR: allocating memory for results 1x1", "frollfunR: 1 column.*1 window.*", "frollfunR: 1:", @@ -322,7 +321,7 @@ test(6000.0672, frollmean(c(1:2,NA,4:10), 4, hasNA=FALSE), c(rep(NA_real_, 6), 5 "frollmean: processing algo 0 took.*", "frollfunR: processing.*took.*" ), warning="hasNA=FALSE used but NA.*are present in input, use default hasNA=NA to avoid this warning") -test(6000.0673, frollmean(c(1:2,NA,4:10), 2, hasNA=FALSE), c(NA, 1.5, NA, NA, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5), output=c( +test(6000.0673, options = c(datatable.verbose=TRUE), frollmean(c(1:2,NA,4:10), 2, hasNA=FALSE), c(NA, 1.5, NA, NA, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5), output=c( "frollfunR: allocating memory for results 1x1", "frollfunR: 1 column.*1 window.*", "frollfunR: 1:", @@ -331,7 +330,7 @@ test(6000.0673, frollmean(c(1:2,NA,4:10), 2, hasNA=FALSE), c(NA, 1.5, NA, NA, 4. "frollmean: processing algo 0 took.*", "frollfunR: processing.*took.*" ), warning="hasNA=FALSE used but NA.*are present in input, use default hasNA=NA to avoid this warning") -test(6000.0674, frollmean(c(1:2,NA,4:10), 4, align="center"), c(rep(NA_real_, 4), 5.5, 6.5, 7.5, 8.5, NA, NA), output=c( +test(6000.0674, options = c(datatable.verbose=TRUE), frollmean(c(1:2,NA,4:10), 4, align="center"), c(rep(NA_real_, 4), 5.5, 6.5, 7.5, 8.5, NA, NA), output=c( "frollfunR: allocating memory for results 1x1", "frollfunR: 1 column.*1 window.*", "frollmeanFast: running for input length 10, window 4, hasna 0, narm 0", @@ -340,7 +339,6 @@ test(6000.0674, frollmean(c(1:2,NA,4:10), 4, align="center"), c(rep(NA_real_, 4) "frollmean: processing algo 0 took.*", "frollfunR: processing.*took.*" )) -options(datatable.verbose=FALSE) #### fill constant test(6000.068, frollmean(1:5, 4, fill=0), c(0, 0, 0, 2.5, 3.5)) @@ -382,9 +380,7 @@ test(6000.092, frollmean(list(1:3, 4:6), c(2, 2)), list(c(NA_real_, 1.5, 2.5), c test(6000.093, frollmean(list(1:3, 4:6), 4), list(c(NA_real_, NA_real_, NA_real_), c(NA_real_, NA_real_, NA_real_))) test(6000.0931, frollmean(list(1:3, 4:6), 4, align="center"), list(c(NA_real_, NA_real_, NA_real_), c(NA_real_, NA_real_, NA_real_))) test(6000.0932, frollmean(list(1:3, 4:6), 4, align="left"), list(c(NA_real_, NA_real_, NA_real_), c(NA_real_, NA_real_, NA_real_))) -options(datatable.verbose=TRUE) -test(6000.0933, frollmean(list(1:3, 4:6), 4), list(c(NA_real_, NA_real_, NA_real_), c(NA_real_, NA_real_, NA_real_)), output="frollmean: window width longer than input vector, returning all NA vector") -options(datatable.verbose=FALSE) +test(6000.0933, options = c(datatable.verbose=TRUE), frollmean(list(1:3, 4:6), 4), list(c(NA_real_, NA_real_, NA_real_), c(NA_real_, NA_real_, NA_real_)), output="frollmean: window width longer than input vector, returning all NA vector") #### n==length(x) test(6000.094, frollmean(list(1:3, 4:6), 3), list(c(NA_real_, NA_real_, 2), c(NA_real_, NA_real_, 5))) #### nlength(x[[2L]]) @@ -431,8 +427,7 @@ test(6000.1194, frollmean(1:5, 2, hasNA=1), error="hasNA must be TRUE, FALSE or #### hasNA=FALSE na.rm=TRUE test(6000.1195, frollmean(1:5, 2, na.rm=TRUE, hasNA=FALSE), error="using hasNA FALSE and na.rm TRUE does not make sense, if you know there are NA values use hasNA TRUE, otherwise leave it as default NA") #### exact na.rm=TRUE adaptive=TRUE verbose=TRUE -options(datatable.verbose=TRUE) -test(6000.1196, frollmean(c(1:5,NA), 1:6, algo="exact", na.rm=TRUE, adaptive=TRUE), output=c( +test(6000.1196, options = c(datatable.verbose=TRUE), frollmean(c(1:5,NA), 1:6, algo="exact", na.rm=TRUE, adaptive=TRUE), output=c( "frollfunR: allocating memory for results 1x1", "frollfunR: 1 column.*1 window.*, not entering parallel execution here because algo='exact' will compute results in parallel", "frollfunR: 1:", @@ -442,7 +437,7 @@ test(6000.1196, frollmean(c(1:5,NA), 1:6, algo="exact", na.rm=TRUE, adaptive=TRU "frollfunR: processing.*took.*" )) #### exact na.rm=TRUE verbose=TRUE -test(6000.1197, frollmean(c(1:5,NA), 2, algo="exact", na.rm=TRUE), output=c( +test(6000.1197, options = c(datatable.verbose=TRUE), frollmean(c(1:5,NA), 2, algo="exact", na.rm=TRUE), output=c( "frollfunR: allocating memory for results 1x1", "frollfunR: 1 column.*1 window.*, not entering parallel execution here because algo='exact' will compute results in parallel", "frollfunR: 1:", @@ -451,7 +446,6 @@ test(6000.1197, frollmean(c(1:5,NA), 2, algo="exact", na.rm=TRUE), output=c( "frollmean: processing algo 1 took.*", "frollfunR: processing.*took.*" )) -options(datatable.verbose=FALSE) #### adaptive=TRUE n=character test(6000.1198, frollmean(1:5, n=letters[1:5], adaptive=TRUE), error="n must be integer vector or list of integer vectors") @@ -658,15 +652,14 @@ test(6000.170, frollmean(x, n, algo="exact", adaptive=TRUE), ama(x, n)) ## test verbose messages x = 1:10 n = 3 -options(datatable.verbose=TRUE) -test(6000.171, frollmean(x, n), output=c( +test(6000.171, options = c(datatable.verbose=TRUE), frollmean(x, n), output=c( "frollfunR: allocating memory for results 1x1", "frollfunR: 1 column.*1 window.*", "frollfunR: 1:", "frollmeanFast: running for input length 10, window 3, hasna 0, narm 0", "frollmean: processing algo 0 took.*", "frollfunR: processing.*took.*")) -test(6000.172, frollmean(list(x, x+1), n), output=c( +test(6000.172, options = c(datatable.verbose=TRUE), frollmean(list(x, x+1), n), output=c( "frollfunR: allocating memory for results 2x1", "frollfunR: 2 column.*1 window.*", "frollfunR: 1:", @@ -676,7 +669,7 @@ test(6000.172, frollmean(list(x, x+1), n), output=c( "frollmeanFast: running for input length 10, window 3, hasna 0, narm 0", "frollmean: processing algo 0 took.*", "frollfunR: processing.*took.*")) -test(6000.173, frollmean(x, c(n, n+1)), output=c( +test(6000.173, options = c(datatable.verbose=TRUE), frollmean(x, c(n, n+1)), output=c( "frollfunR: allocating memory for results 1x2", "frollfunR: 1 column.*2 window.*", "frollfunR: 1:", @@ -686,7 +679,7 @@ test(6000.173, frollmean(x, c(n, n+1)), output=c( "frollmeanFast: running for input length 10, window 4, hasna 0, narm 0", "frollmean: processing algo 0 took.*", "frollfunR: processing.*took.*")) -test(6000.174, frollmean(list(x, x+1), c(n, n+1)), output=c( +test(6000.174, options = c(datatable.verbose=TRUE), frollmean(list(x, x+1), c(n, n+1)), output=c( "frollfunR: allocating memory for results 2x2", "frollfunR: 2 column.*2 window.*", "frollfunR: 1:", @@ -702,14 +695,14 @@ test(6000.174, frollmean(list(x, x+1), c(n, n+1)), output=c( "frollmeanFast: running for input length 10, window 4, hasna 0, narm 0", "frollmean: processing algo 0 took.*", "frollfunR: processing.*took.*")) -test(6000.175, frollmean(x, n, algo="exact"), output=c( +test(6000.175, options = c(datatable.verbose=TRUE), frollmean(x, n, algo="exact"), output=c( "frollfunR: allocating memory for results 1x1", "frollfunR: 1 column.*1 window.*", "frollfunR: 1:", "frollmeanExact: running in parallel for input length 10, window 3, hasna 0, narm 0", "frollmean: processing algo 1 took.*", "frollfunR: processing.*took.*")) -test(6000.176, frollmean(x, n, align="center"), output=c( +test(6000.176, options = c(datatable.verbose=TRUE), frollmean(x, n, align="center"), output=c( "frollfunR: allocating memory for results 1x1", "frollfunR: 1 column.*1 window.*", "frollfunR: 1:", @@ -717,7 +710,7 @@ test(6000.176, frollmean(x, n, align="center"), output=c( "frollmean: align 0, shift answer by -1", "frollmean: processing algo 0 took.*", "frollfunR: processing.*took.*")) -test(6000.177, frollmean(x, n, align="left"), output=c( +test(6000.177, options = c(datatable.verbose=TRUE), frollmean(x, n, align="left"), output=c( "frollfunR: allocating memory for results 1x1", "frollfunR: 1 column.*1 window.*", "frollfunR: 1:", @@ -726,14 +719,14 @@ test(6000.177, frollmean(x, n, align="left"), output=c( "frollmean: processing algo 0 took.*", "frollfunR: processing.*took.*")) nn = c(1:4,2:3,1:4) -test(6000.178, frollmean(x, nn, adaptive=TRUE), output=c( +test(6000.178, options = c(datatable.verbose=TRUE), frollmean(x, nn, adaptive=TRUE), output=c( "frollfunR: allocating memory for results 1x1", "frollfunR: 1 column.*1 window.*", "frollfunR: 1:", "fadaptiverollmeanFast: running for input length 10, hasna 0, narm 0", "fadaptiverollmean: processing algo 0 took.*", "frollfunR: processing.*took.*")) -test(6000.179, frollmean(x, nn, algo="exact", adaptive=TRUE), output=c( +test(6000.179, options = c(datatable.verbose=TRUE), frollmean(x, nn, algo="exact", adaptive=TRUE), output=c( "frollfunR: allocating memory for results 1x1", "frollfunR: 1 column.*1 window.*", "frollfunR: 1:", @@ -742,7 +735,7 @@ test(6000.179, frollmean(x, nn, algo="exact", adaptive=TRUE), output=c( "frollfunR: processing.*took.*")) x[8] = NA -test(6000.180, frollmean(x, n), output=c( +test(6000.180, options = c(datatable.verbose=TRUE), frollmean(x, n), output=c( "frollfunR: allocating memory for results 1x1", "frollfunR: 1 column.*1 window.*", "frollfunR: 1:", @@ -750,7 +743,7 @@ test(6000.180, frollmean(x, n), output=c( "frollmeanFast: NA.*are present in input, re-running with extra care for NAs", "frollmean: processing algo 0 took.*", "frollfunR: processing.*took.*")) -test(6000.181, frollmean(x, n, algo="exact"), output=c( +test(6000.181, options = c(datatable.verbose=TRUE), frollmean(x, n, algo="exact"), output=c( "frollfunR: allocating memory for results 1x1", "frollfunR: 1 column.*1 window.*", "frollfunR: 1:", @@ -758,7 +751,7 @@ test(6000.181, frollmean(x, n, algo="exact"), output=c( "frollmeanExact: NA.*are present in input, na.rm was FALSE so in 'exact' implementation NAs were handled already, no need to re-run", "frollmean: processing algo 1 took.*", "frollfunR: processing.*took.*")) -test(6000.182, frollmean(x, nn, adaptive=TRUE), output=c( +test(6000.182, options = c(datatable.verbose=TRUE), frollmean(x, nn, adaptive=TRUE), output=c( "frollfunR: allocating memory for results 1x1", "frollfunR: 1 column.*1 window.*", "frollfunR: 1:", @@ -766,7 +759,7 @@ test(6000.182, frollmean(x, nn, adaptive=TRUE), output=c( "fadaptiverollmeanFast: NA.*are present in input, re-running with extra care for NAs", "fadaptiverollmean: processing algo 0 took.*", "frollfunR: processing.*took.*")) -test(6000.183, frollmean(x, nn, algo="exact", adaptive=TRUE), output=c( +test(6000.183, options = c(datatable.verbose=TRUE), frollmean(x, nn, algo="exact", adaptive=TRUE), output=c( "frollfunR: allocating memory for results 1x1", "frollfunR: 1 column.*1 window.*", "frollfunR: 1:", @@ -776,7 +769,7 @@ test(6000.183, frollmean(x, nn, algo="exact", adaptive=TRUE), output=c( "frollfunR: processing.*took.*")) d = as.data.table(list(1:10/2, 10:1/4)) -test(6000.184, frollmean(d[,1], 3, algo="exact"), output=c( +test(6000.184, options = c(datatable.verbose=TRUE), frollmean(d[,1], 3, algo="exact"), output=c( "frollfunR: allocating memory for results 1x1", "frollfunR: 1 column.*1 window.*", "frollfunR: 1:", @@ -784,7 +777,7 @@ test(6000.184, frollmean(d[,1], 3, algo="exact"), output=c( "frollmean: processing algo 1 took.*", "frollfunR: processing.*took.*" )) -test(6000.185, frollmean(d, 3:4, algo="exact"), output=c( +test(6000.185, options = c(datatable.verbose=TRUE), frollmean(d, 3:4, algo="exact"), output=c( "frollfunR: allocating memory for results 2x2", "frollfunR: 2 column.*2 window.*", "frollfunR: 1:", @@ -801,7 +794,6 @@ test(6000.185, frollmean(d, 3:4, algo="exact"), output=c( "frollmean: processing algo 1 took.*", "frollfunR: processing.*took.*" )) -options(datatable.verbose=FALSE) ## test warnings test(6000.186, frollmean(c(1:2,NA,4:10), 4, hasNA=FALSE), c(rep(NA_real_, 6), 5.5, 6.5, 7.5, 8.5), warning="hasNA=FALSE used but NA.*are present in input, use default hasNA=NA to avoid this warning") @@ -823,28 +815,22 @@ ans1 = frollsum(x, n, adaptive=TRUE) expected = c(NA_real_, 1.5, 3, 5, 4.5, 7.5) test(6000.202, ans1, expected) ## frollsum coverage -options(datatable.verbose=TRUE) -test(6000.211, frollsum(1:5, 6), rep(NA_real_, 5L), output="window width longer than input vector") -options(datatable.verbose=FALSE) +test(6000.211, options = c(datatable.verbose=TRUE), frollsum(1:5, 6), rep(NA_real_, 5L), output="window width longer than input vector") test(6000.212, frollsum(c(1:2,NA,4:10), 4, hasNA=FALSE), c(rep(NA_real_, 6), 22, 26, 30, 34), warning="hasNA=FALSE used but NA.*are present in input, use default hasNA=NA to avoid this warning") test(6000.213, frollsum(c(1:2,NA,4:10), 2, hasNA=FALSE), c(NA, 3, NA, NA, 9, 11, 13, 15, 17, 19), warning="hasNA=FALSE used but NA.*are present in input, use default hasNA=NA to avoid this warning") test(6000.214, frollsum(c(1:2,NA,4:10), 4, hasNA=FALSE, algo="exact"), c(rep(NA_real_, 6), 22, 26, 30, 34), warning="hasNA=FALSE used but NA.*are present in input, use default hasNA=NA to avoid this warning") -options(datatable.verbose=TRUE) -test(6000.215, frollsum(c(1:2,NA,4:10), 4, algo="exact", na.rm=TRUE), c(rep(NA_real_, 3L), 7, 11, 15, 22, 26, 30, 34), output="re-running with extra care for NAs") -test(6000.216, frollsum(c(1:2,NA,4:10), 4, algo="exact"), c(rep(NA_real_, 6), 22, 26, 30, 34), output="NAs were handled already, no need to re-run") -options(datatable.verbose=FALSE) +test(6000.215, options = c(datatable.verbose=TRUE), frollsum(c(1:2,NA,4:10), 4, algo="exact", na.rm=TRUE), c(rep(NA_real_, 3L), 7, 11, 15, 22, 26, 30, 34), output="re-running with extra care for NAs") +test(6000.216, options = c(datatable.verbose=TRUE), frollsum(c(1:2,NA,4:10), 4, algo="exact"), c(rep(NA_real_, 6), 22, 26, 30, 34), output="NAs were handled already, no need to re-run") test(6000.217, frollsum(c(1:2,NA,4:10), rep(4L,10), adaptive=TRUE, hasNA=FALSE), c(rep(NA_real_, 6), 22, 26, 30, 34), warning="*hasNA=FALSE used but NA.*are present in input, use default hasNA=NA to avoid this warning") test(6000.218, frollsum(c(1:2,NA,4:10), rep(4L,10), adaptive=TRUE, hasNA=FALSE, algo="exact"), c(rep(NA_real_, 6), 22, 26, 30, 34), warning="hasNA=FALSE used but NA.*are present in input, use default hasNA=NA to avoid this warning") -options(datatable.verbose=TRUE) -test(6000.219, frollsum(c(1:2,NA,4:10), rep(4L,10), adaptive=TRUE, algo="exact", na.rm=TRUE), c(rep(NA_real_, 3L), 7, 11, 15, 22, 26, 30, 34), output="re-running with extra care for NAs") -test(6000.220, frollsum(c(1:2,NA,4:10), rep(4L,10), adaptive=TRUE, algo="exact"), c(rep(NA_real_, 6), 22, 26, 30, 34), output="NAs were handled already, no need to re-run") -test(6000.221, frollsum(1:3, 2), c(NA, 3, 5), output="frollsumFast: running for input length") -test(6000.222, frollsum(1:3, 2, align="left"), c(3, 5, NA), output="frollsum: align") -test(6000.223, frollsum(c(1,2,NA), 2), c(NA, 3, NA), output="re-running with extra care for NAs") -test(6000.224, frollsum(c(NA,2,3), 2), c(NA, NA, 5), output="skip non-NA attempt and run with extra care for NAs") -test(6000.225, frollsum(1:3, c(2,2,2), adaptive=TRUE), c(NA, 3, 5), output="fadaptiverollsumFast: running for input length") -test(6000.226, frollsum(c(NA,2,3), c(2,2,2), adaptive=TRUE), c(NA, NA, 5), output="re-running with extra care for NAs") -options(datatable.verbose=FALSE) +test(6000.219, options = c(datatable.verbose=TRUE), frollsum(c(1:2,NA,4:10), rep(4L,10), adaptive=TRUE, algo="exact", na.rm=TRUE), c(rep(NA_real_, 3L), 7, 11, 15, 22, 26, 30, 34), output="re-running with extra care for NAs") +test(6000.220, options = c(datatable.verbose=TRUE), frollsum(c(1:2,NA,4:10), rep(4L,10), adaptive=TRUE, algo="exact"), c(rep(NA_real_, 6), 22, 26, 30, 34), output="NAs were handled already, no need to re-run") +test(6000.221, options = c(datatable.verbose=TRUE), frollsum(1:3, 2), c(NA, 3, 5), output="frollsumFast: running for input length") +test(6000.222, options = c(datatable.verbose=TRUE), frollsum(1:3, 2, align="left"), c(3, 5, NA), output="frollsum: align") +test(6000.223, options = c(datatable.verbose=TRUE), frollsum(c(1,2,NA), 2), c(NA, 3, NA), output="re-running with extra care for NAs") +test(6000.224, options = c(datatable.verbose=TRUE), frollsum(c(NA,2,3), 2), c(NA, NA, 5), output="skip non-NA attempt and run with extra care for NAs") +test(6000.225, options = c(datatable.verbose=TRUE), frollsum(1:3, c(2,2,2), adaptive=TRUE), c(NA, 3, 5), output="fadaptiverollsumFast: running for input length") +test(6000.226, options = c(datatable.verbose=TRUE), frollsum(c(NA,2,3), c(2,2,2), adaptive=TRUE), c(NA, NA, 5), output="re-running with extra care for NAs") ## validation @@ -1048,20 +1034,18 @@ f = function(x) { if (n==x[n]) x[1L] else range(x) # range(x)[2L] is silently ignored } test(6010.102, frollapply(1:5, 3, f), c(NA,NA,1,2,3)) -options(datatable.verbose=TRUE) x = c(1,2,1,1,1,2,3,2) ans = c(NA,NA,2,2,1,2,3,2) numUniqueN = function(x) as.numeric(uniqueN(x)) -test(6010.103, frollapply(x, 3, uniqueN), ans, output=c("frollapplyR: allocating memory.*","frollapply: results from provided FUN are not of type double, coercion from integer or logical will be applied on each iteration.*","frollapply: took.*","frollapplyR: processing.*took.*")) -test(6010.104, frollapply(x, 3, numUniqueN), ans, output=c("frollapplyR: allocating memory.*","frollapply: took.*","frollapplyR: processing.*took.*")) -test(6010.105, as.logical(frollapply(c(1,2,1,1,NA,2,NA,2), 3, anyNA)), c(NA,NA,FALSE,FALSE,TRUE,TRUE,TRUE,TRUE), output=c("frollapplyR: allocating memory.*","frollapply: results from provided FUN are not of type double, coercion from integer or logical will be applied on each iteration","frollapply: took.*","frollapplyR: processing.*took.*")) +test(6010.103, options = c(datatable.verbose=TRUE), frollapply(x, 3, uniqueN), ans, output=c("frollapplyR: allocating memory.*","frollapply: results from provided FUN are not of type double, coercion from integer or logical will be applied on each iteration.*","frollapply: took.*","frollapplyR: processing.*took.*")) +test(6010.104, options = c(datatable.verbose=TRUE), frollapply(x, 3, numUniqueN), ans, output=c("frollapplyR: allocating memory.*","frollapply: took.*","frollapplyR: processing.*took.*")) +test(6010.105, options = c(datatable.verbose=TRUE), as.logical(frollapply(c(1,2,1,1,NA,2,NA,2), 3, anyNA)), c(NA,NA,FALSE,FALSE,TRUE,TRUE,TRUE,TRUE), output=c("frollapplyR: allocating memory.*","frollapply: results from provided FUN are not of type double, coercion from integer or logical will be applied on each iteration","frollapply: took.*","frollapplyR: processing.*took.*")) f = function(x) { n = length(x) # double type will be returned only for first iteration where we check type if (n==x[n]) 1 else NA # NA logical turns into garbage without coercion to double } #test(6010.106, head(frollapply(1:5, 3, f), 3L), c(NA_real_,NA_real_,1), output=c("frollapplyR: allocating memory.*","frollapply: took.*","frollapplyR: processing.*took.*")) # only head 3 is valid, rest is undefined as REAL is applied on logical type, can return garbage or fail with REAL error -options(datatable.verbose=FALSE) #### test coverage test(6010.501, frollapply(1:3, "b", sum), error="n must be integer") test(6010.502, frollapply(1:3, 2.5, sum), error="n must be integer") @@ -1090,11 +1074,9 @@ test(6010.524, frollapply(c(1,2,3,NA,NA,NA,NA), 3L, mean), c(NA,NA,2,NA,NA,NA,NA test(6010.525, frollapply(c(1,2,3,NA,NA,NA,NA), 3L, mean, na.rm=TRUE), c(NA,NA,2,2.5,3,NaN,NaN)) test(6010.526, frollapply(numeric(), 3L, sum), numeric()) test(6010.527, frollapply(1:5, 3L, toString), error="frollapply: results from provided FUN are not of type double") -options(datatable.verbose=TRUE) -test(6010.551, frollapply(1:3, 4L, sum), c(NA_real_,NA_real_,NA_real_), output=c("frollapplyR: allocating memory.*","frollapply: window width longer than input vector.*","frollapplyR: processing.*took.*")) -test(6010.552, frollapply(1:5, 3L, sum), c(NA,NA,6,9,12), output=c("frollapplyR: allocating memory.*","frollapply: took.*","frollapplyR: processing.*took.*")) -test(6010.553, frollapply(1:5, 3L, sum, align="center"), c(NA,6,9,12,NA), output=c("frollapplyR: allocating memory.*","frollapply: align 0, shift.*","frollapply: took.*","frollapplyR: processing.*took.*")) -options(datatable.verbose=FALSE) +test(6010.551, options = c(datatable.verbose=TRUE), frollapply(1:3, 4L, sum), c(NA_real_,NA_real_,NA_real_), output=c("frollapplyR: allocating memory.*","frollapply: window width longer than input vector.*","frollapplyR: processing.*took.*")) +test(6010.552, options = c(datatable.verbose=TRUE), frollapply(1:5, 3L, sum), c(NA,NA,6,9,12), output=c("frollapplyR: allocating memory.*","frollapply: took.*","frollapplyR: processing.*took.*")) +test(6010.553, options = c(datatable.verbose=TRUE), frollapply(1:5, 3L, sum, align="center"), c(NA,6,9,12,NA), output=c("frollapplyR: allocating memory.*","frollapply: align 0, shift.*","frollapply: took.*","frollapplyR: processing.*took.*")) ma = function(x, n, na.rm=FALSE) { ans = rep(NA_real_, nx<-length(x)) for (i in n:nx) ans[i]=mean(x[(i-n+1):i], na.rm=na.rm) diff --git a/inst/tests/nafill.Rraw b/inst/tests/nafill.Rraw index b72c0b5063..5d12828760 100644 --- a/inst/tests/nafill.Rraw +++ b/inst/tests/nafill.Rraw @@ -154,13 +154,11 @@ test(4.24, colnamesInt(dt, "a"), error="has no names") # verbose dt = data.table(a=c(1L, 2L, NA_integer_), b=c(1, 2, NA_real_)) -old=options(datatable.verbose=TRUE) -test(5.01, nafill(dt, "locf"), output="nafillInteger: took.*nafillDouble: took.*nafillR.*took") -test(5.02, setnafill(dt, "locf"), output="nafillInteger: took.*nafillDouble: took.*nafillR.*took") +test(5.01, options = c(datatable.verbose=TRUE), nafill(dt, "locf"), output="nafillInteger: took.*nafillDouble: took.*nafillR.*took") +test(5.02, options = c(datatable.verbose=TRUE), setnafill(dt, "locf"), output="nafillInteger: took.*nafillDouble: took.*nafillR.*took") if (test_bit64) { - test(5.03, nafill(as.integer64(c(NA,2,NA,3)), "locf"), as.integer64(c(NA,2,2,3)), output="nafillInteger64: took.*nafillR.*took") + test(5.03, options = c(datatable.verbose=TRUE), nafill(as.integer64(c(NA,2,NA,3)), "locf"), as.integer64(c(NA,2,2,3)), output="nafillInteger64: took.*nafillR.*took") } -options(old) # coerceAs int/numeric/int64 as used in nafill if (test_bit64) { @@ -243,65 +241,61 @@ if (test_bit64) { } # coerceAs verbose -options(datatable.verbose=2L) input = 1 -test(10.01, ans<-coerceAs(input, 1), 1, output="double[numeric] into double[numeric]") -test(10.02, address(input)!=address(ans)) -test(10.03, ans<-coerceAs(input, 1, copy=FALSE), 1, output="copy=false and input already of expected type and class double[numeric]") -test(10.04, address(input), address(ans)) -test(10.05, ans<-coerceAs(input, 1L), 1L, output="double[numeric] into integer[integer]") -test(10.06, address(input)!=address(ans)) -test(10.07, ans<-coerceAs(input, 1L, copy=FALSE), 1L, output="double[numeric] into integer[integer]", notOutput="copy=false") -test(10.08, address(input)!=address(ans)) -test(10.09, coerceAs("1", 1L), 1L, output="character[character] into integer[integer]", warning="Coercing.*character.*integer") -test(10.10, coerceAs("1", 1), 1, output="character[character] into double[numeric]", warning="Coercing.*character.*double") -test(10.11, coerceAs("a", factor("x")), factor("a", levels=c("x","a")), output="character[character] into integer[factor]") ## levels of 'as' are retained! -test(10.12, coerceAs("a", factor()), factor("a"), output="character[character] into integer[factor]") -test(10.13, coerceAs(1, factor("x")), factor("x"), output="double[numeric] into integer[factor]") -test(10.14, coerceAs(1, factor("x", levels=c("x","y"))), factor("x", levels=c("x","y")), output="double[numeric] into integer[factor]") -test(10.15, coerceAs(2, factor("x", levels=c("x","y"))), factor("y", levels=c("x","y")), output="double[numeric] into integer[factor]") -test(10.16, coerceAs(1:2, factor(c("x","y"))), factor(c("x","y")), output="integer[integer] into integer[factor]") -test(10.17, coerceAs(1:3, factor(c("x","y"))), output="integer[integer] into integer[factor]", error="factor numbers.*3 is outside the level range") -test(10.18, coerceAs(c(1,2,3), factor(c("x","y"))), output="double[numeric] into integer[factor]", error="factor numbers.*3.000000 is outside the level range") -test(10.19, coerceAs(factor("x"), factor(c("x","y"))), factor("x", levels=c("x","y")), output="integer[factor] into integer[factor]") -test(10.20, coerceAs(factor("x"), factor(c("x","y")), copy=FALSE), factor("x", levels=c("x","y")), output="input already of expected type and class") ## copy=F has copyMostAttrib +test(10.01, options = c(datatable.verbose=2L), ans<-coerceAs(input, 1), 1, output="double[numeric] into double[numeric]") +test(10.02, options = c(datatable.verbose=2L), address(input)!=address(ans)) +test(10.03, options = c(datatable.verbose=2L), ans<-coerceAs(input, 1, copy=FALSE), 1, output="copy=false and input already of expected type and class double[numeric]") +test(10.04, options = c(datatable.verbose=2L), address(input), address(ans)) +test(10.05, options = c(datatable.verbose=2L), ans<-coerceAs(input, 1L), 1L, output="double[numeric] into integer[integer]") +test(10.06, options = c(datatable.verbose=2L), address(input)!=address(ans)) +test(10.07, options = c(datatable.verbose=2L), ans<-coerceAs(input, 1L, copy=FALSE), 1L, output="double[numeric] into integer[integer]", notOutput="copy=false") +test(10.08, options = c(datatable.verbose=2L), address(input)!=address(ans)) +test(10.09, options = c(datatable.verbose=2L), coerceAs("1", 1L), 1L, output="character[character] into integer[integer]", warning="Coercing.*character.*integer") +test(10.10, options = c(datatable.verbose=2L), coerceAs("1", 1), 1, output="character[character] into double[numeric]", warning="Coercing.*character.*double") +test(10.11, options = c(datatable.verbose=2L), coerceAs("a", factor("x")), factor("a", levels=c("x","a")), output="character[character] into integer[factor]") ## levels of 'as' are retained! +test(10.12, options = c(datatable.verbose=2L), coerceAs("a", factor()), factor("a"), output="character[character] into integer[factor]") +test(10.13, options = c(datatable.verbose=2L), coerceAs(1, factor("x")), factor("x"), output="double[numeric] into integer[factor]") +test(10.14, options = c(datatable.verbose=2L), coerceAs(1, factor("x", levels=c("x","y"))), factor("x", levels=c("x","y")), output="double[numeric] into integer[factor]") +test(10.15, options = c(datatable.verbose=2L), coerceAs(2, factor("x", levels=c("x","y"))), factor("y", levels=c("x","y")), output="double[numeric] into integer[factor]") +test(10.16, options = c(datatable.verbose=2L), coerceAs(1:2, factor(c("x","y"))), factor(c("x","y")), output="integer[integer] into integer[factor]") +test(10.17, options = c(datatable.verbose=2L), coerceAs(1:3, factor(c("x","y"))), output="integer[integer] into integer[factor]", error="factor numbers.*3 is outside the level range") +test(10.18, options = c(datatable.verbose=2L), coerceAs(c(1,2,3), factor(c("x","y"))), output="double[numeric] into integer[factor]", error="factor numbers.*3.000000 is outside the level range") +test(10.19, options = c(datatable.verbose=2L), coerceAs(factor("x"), factor(c("x","y"))), factor("x", levels=c("x","y")), output="integer[factor] into integer[factor]") +test(10.20, options = c(datatable.verbose=2L), coerceAs(factor("x"), factor(c("x","y")), copy=FALSE), factor("x", levels=c("x","y")), output="input already of expected type and class") ## copy=F has copyMostAttrib a = structure("a", class="a") b = structure("b", class="b") -test(10.21, coerceAs(a, b), structure("a", class="b"), output="character[a] into character[b]") +test(10.21, options = c(datatable.verbose=2L), coerceAs(a, b), structure("a", class="b"), output="character[a] into character[b]") a = structure(1L, class="a") b = structure(2L, class="b") -test(10.22, coerceAs(a, b), structure(1L, class="b"), output="integer[a] into integer[b]") +test(10.22, options = c(datatable.verbose=2L), coerceAs(a, b), structure(1L, class="b"), output="integer[a] into integer[b]") a = structure(1, class="a") b = structure(2, class="b") -test(10.23, coerceAs(a, b), structure(1, class="b"), output="double[a] into double[b]") +test(10.23, options = c(datatable.verbose=2L), coerceAs(a, b), structure(1, class="b"), output="double[a] into double[b]") a = structure(1, class="a") b = structure(2L, class="b") -test(10.24, coerceAs(a, b), structure(1L, class="b"), output="double[a] into integer[b]") +test(10.24, options = c(datatable.verbose=2L), coerceAs(a, b), structure(1L, class="b"), output="double[a] into integer[b]") if (test_bit64) { x = as.integer64(1L) - test(10.81, coerceAs(x, 1), 1, output="double[integer64] into double[numeric]") - test(10.82, coerceAs(x, 1L), 1L, output="double[integer64] into integer[integer]") - test(10.83, coerceAs(x, "1"), "1", output="double[integer64] into character[character]") - test(10.84, coerceAs(1, x), x, output="double[numeric] into double[integer64]") - test(10.85, coerceAs(1L, x), x, output="integer[integer] into double[integer64]") - test(10.86, coerceAs("1", x), x, output="character[character] into double[integer64]", warning="Coercing.*character") - options(datatable.verbose=3L) - test(10.87, coerceAs(x, 1L), 1L, output=c("double[integer64] into integer[integer]","Zero-copy coerce when assigning 'integer64' to 'integer'")) - test(10.88, coerceAs(1L, x), x, output=c("integer[integer] into double[integer64]","Zero-copy coerce when assigning 'integer' to 'integer64'")) - options(datatable.verbose=2L) - test(10.89, coerceAs(-2147483649, x), as.integer64(-2147483649), output="double[numeric] into double[integer64]") + test(10.81, options = c(datatable.verbose=2L), coerceAs(x, 1), 1, output="double[integer64] into double[numeric]") + test(10.82, options = c(datatable.verbose=2L), coerceAs(x, 1L), 1L, output="double[integer64] into integer[integer]") + test(10.83, options = c(datatable.verbose=2L), coerceAs(x, "1"), "1", output="double[integer64] into character[character]") + test(10.84, options = c(datatable.verbose=2L), coerceAs(1, x), x, output="double[numeric] into double[integer64]") + test(10.85, options = c(datatable.verbose=2L), coerceAs(1L, x), x, output="integer[integer] into double[integer64]") + test(10.86, options = c(datatable.verbose=2L), coerceAs("1", x), x, output="character[character] into double[integer64]", warning="Coercing.*character") + test(10.87, options = c(datatable.verbose=3L), coerceAs(x, 1L), 1L, output=c("double[integer64] into integer[integer]","Zero-copy coerce when assigning 'integer64' to 'integer'")) + test(10.88, options = c(datatable.verbose=3L), coerceAs(1L, x), x, output=c("integer[integer] into double[integer64]","Zero-copy coerce when assigning 'integer' to 'integer64'")) + test(10.89, options = c(datatable.verbose=2L), 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") + test(10.91, options = c(datatable.verbose=2L), coerceAs(x, 1), 1, output="double[nanotime] into double[numeric]") + test(10.92, options = c(datatable.verbose=2L), coerceAs(x, 1L), 1L, output="double[nanotime] into integer[integer]") + test(10.93, 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(10.94, options = c(datatable.verbose=2L), coerceAs(1, x), x, output="double[numeric] into double[nanotime]") + test(10.95, options = c(datatable.verbose=2L), coerceAs(1L, x), x, output="integer[integer] into double[nanotime]") + test(10.96, options = c(datatable.verbose=2L), coerceAs("1", x), x, output="character[character] into double[nanotime]", warning="Coercing.*character") } -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)) test(11.03, coerceAs(sum, 1), error="is not atomic") @@ -328,7 +322,4 @@ test(11.09, coerceAs(1L, a), error="must not be matrix or array") test(99.1, data.table(a=1,b=2)[1,1, verbose=1], error="verbose must be logical or integer") test(99.2, data.table(a=1,b=2)[1,1, verbose=1:2], error="verbose must be length 1 non-NA") test(99.3, data.table(a=1,b=2)[1,1, verbose=NA], error="verbose must be length 1 non-NA") -options(datatable.verbose=1) -test(99.4, coerceAs(1, 2L), error="verbose option must be length 1 non-NA logical or integer") -options(datatable.verbose=FALSE) - +test(99.4, options = c(datatable.verbose=1), coerceAs(1, 2L), error="verbose option must be length 1 non-NA logical or integer") diff --git a/inst/tests/other.Rraw b/inst/tests/other.Rraw index 88593bcdf5..b80f1e0b48 100644 --- a/inst/tests/other.Rraw +++ b/inst/tests/other.Rraw @@ -497,13 +497,11 @@ if (loaded[["xts"]]) { # was 1465 in tests.Rraw, #5516 # 890 -- key argument for as.data.table.xts x = xts(1:10, as.Date(1:10, origin = "1970-01-01")) - old = options(datatable.verbose=FALSE) - test(18.18, capture.output(as.data.table(x, key="index")), + test(18.18, options = c(datatable.verbose=FALSE), capture.output(as.data.table(x, key="index")), c(" index V1", " 1: 1970-01-02 1", " 2: 1970-01-03 2", " 3: 1970-01-04 3", " 4: 1970-01-05 4", " 5: 1970-01-06 5", " 6: 1970-01-07 6", " 7: 1970-01-08 7", " 8: 1970-01-09 8", " 9: 1970-01-10 9", "10: 1970-01-11 10")) - options(old) # as.data.table.xts(foo) had incorrect integer index with a column name called 'x', #4897 M = xts::as.xts(matrix(1, dimnames=list("2021-05-23", "x"))) # xts:: just to be extra robust; shouldn't be needed with rm(as.xts) above @@ -519,22 +517,20 @@ if (loaded[["xts"]]) { # was 1465 in tests.Rraw, #5516 # first and last should no longer load xts namespace, #3857, below commented test for interactive validation when xts present but not loaded or attached # stopifnot("xts"%in%installed.packages(), !"xts"%in%loadedNamespaces()); library(data.table); x=as.POSIXct("2019-01-01"); last(x); stopifnot(!"xts" %in% loadedNamespaces()) x = as.POSIXct("2019-09-09")+0:1 -old = options(datatable.verbose=TRUE) -test(19.01, last(x), x[length(x)], output="!is.xts(x)") -test(19.02, first(x), x[1L], output="!is.xts(x)") +test(19.01, options = c(datatable.verbose=TRUE), last(x), x[length(x)], output="!is.xts(x)") +test(19.02, options = c(datatable.verbose=TRUE), first(x), x[1L], output="!is.xts(x)") if (loaded[["xts"]]) { xt = xts(1:2, x) - test(19.03, last(xt, 2L), xt, output="using xts::last: is.xts(x)") - test(19.04, first(xt, 2L), xt, output="using xts::first: is.xts(x)") + test(19.03, options = c(datatable.verbose=TRUE), last(xt, 2L), xt, output="using xts::last: is.xts(x)") + test(19.04, options = c(datatable.verbose=TRUE), first(xt, 2L), xt, output="using xts::first: is.xts(x)") xt = xts(matrix(1:4, 2L, 2L), x) - test(19.05, last(xt, 2L), xt, output="using xts::last: is.xts(x)") - test(19.06, first(xt, 2L), xt, output="using xts::first: is.xts(x)") + test(19.05, options = c(datatable.verbose=TRUE), last(xt, 2L), xt, output="using xts::last: is.xts(x)") + test(19.06, options = c(datatable.verbose=TRUE), first(xt, 2L), xt, output="using xts::first: is.xts(x)") } # first on empty df now match head(df, n=1L), #3858 df = data.frame(a=integer(), b=integer()) -test(19.11, first(df), df, output="!is.xts(x)") -test(19.12, last(df), df, output="!is.xts(x)") -options(datatable.verbose=FALSE) # so the as.data.table() doesn't pollute output +test(19.11, options = c(datatable.verbose=TRUE), first(df), df, output="!is.xts(x)") +test(19.12, options = c(datatable.verbose=TRUE), last(df), df, output="!is.xts(x)") # xts last-first dispatch fix #4053 x = 1:3 y = as.POSIXct(x, origin="1970-01-01") @@ -550,12 +546,11 @@ xt = structure( index = structure(c(1167782400, 1167868800, 1167955200), tzone = "UTC", tclass = "Date"), .Dim = c(3L, 6L), .Dimnames = list(NULL, c("SPY.Open", "SPY.High", "SPY.Low", "SPY.Close", "SPY.Volume", "SPY.Adjusted")) ) -options(datatable.verbose=TRUE) if (loaded[["xts"]]) { - test(19.21, last(x, n=2L), 2:3, output="using xts::last: !is.xts(x) & nargs>1 & 'package:xts'%in%search()") - test(19.22, last(y, n=2L), y[2:3], output="using xts::last: !is.xts(x) & nargs>1 & 'package:xts'%in%search()") - test(19.23, last(x, n=1L), 3L, output="using xts::last: !is.xts(x) & nargs>1 & 'package:xts'%in%search()") - test(19.24, last(y, n=1L), y[3L], output="using xts::last: !is.xts(x) & nargs>1 & 'package:xts'%in%search()") + test(19.21, options = c(datatable.verbose=TRUE), last(x, n=2L), 2:3, output="using xts::last: !is.xts(x) & nargs>1 & 'package:xts'%in%search()") + test(19.22, options = c(datatable.verbose=TRUE), last(y, n=2L), y[2:3], output="using xts::last: !is.xts(x) & nargs>1 & 'package:xts'%in%search()") + test(19.23, options = c(datatable.verbose=TRUE), last(x, n=1L), 3L, output="using xts::last: !is.xts(x) & nargs>1 & 'package:xts'%in%search()") + test(19.24, options = c(datatable.verbose=TRUE), last(y, n=1L), y[3L], output="using xts::last: !is.xts(x) & nargs>1 & 'package:xts'%in%search()") xt_last = structure( c(141.330002, 141.399994, 140.380005, 140.539993, 76645300, 108.360008), class = c("xts", "zoo"), .indexCLASS = "Date", tclass = "Date", .indexTZ = "UTC", tzone = "UTC", @@ -569,12 +564,12 @@ if (loaded[["xts"]]) { index = structure(c(1167868800, 1167955200), tzone = "UTC", tclass = "Date"), .Dim = c(2L, 6L), .Dimnames = list(NULL, c("SPY.Open", "SPY.High", "SPY.Low", "SPY.Close", "SPY.Volume", "SPY.Adjusted")) ) - test(19.25, last(xt), xt_last, output="using xts::last: is.xts(x)") - test(19.26, last(xt, n=2L), xt_last2, output="using xts::last: is.xts(x)") - test(19.31, first(x, n=2L), 1:2, output="using xts::first: !is.xts(x) & nargs>1 & 'package:xts'%in%search()") - test(19.32, first(y, n=2L), y[1:2], output="using xts::first: !is.xts(x) & nargs>1 & 'package:xts'%in%search()") - test(19.33, first(x, n=1L), 1L, output="using xts::first: !is.xts(x) & nargs>1 & 'package:xts'%in%search()") - test(19.34, first(y, n=1L), y[1L], output="using xts::first: !is.xts(x) & nargs>1 & 'package:xts'%in%search()") + test(19.25, options = c(datatable.verbose=TRUE), last(xt), xt_last, output="using xts::last: is.xts(x)") + test(19.26, options = c(datatable.verbose=TRUE), last(xt, n=2L), xt_last2, output="using xts::last: is.xts(x)") + test(19.31, options = c(datatable.verbose=TRUE), first(x, n=2L), 1:2, output="using xts::first: !is.xts(x) & nargs>1 & 'package:xts'%in%search()") + test(19.32, options = c(datatable.verbose=TRUE), first(y, n=2L), y[1:2], output="using xts::first: !is.xts(x) & nargs>1 & 'package:xts'%in%search()") + test(19.33, options = c(datatable.verbose=TRUE), first(x, n=1L), 1L, output="using xts::first: !is.xts(x) & nargs>1 & 'package:xts'%in%search()") + test(19.34, options = c(datatable.verbose=TRUE), first(y, n=1L), y[1L], output="using xts::first: !is.xts(x) & nargs>1 & 'package:xts'%in%search()") xt_first = structure( c(142.25, 142.860001, 140.570007, 141.369995, 94807600, 108.999954), class = c("xts", "zoo"), .indexCLASS = "Date", tclass = "Date", .indexTZ = "UTC", tzone = "UTC", @@ -587,38 +582,37 @@ if (loaded[["xts"]]) { index = structure(c(1167782400, 1167868800), tzone = "UTC", tclass = "Date"), .Dim = c(2L, 6L), .Dimnames = list(NULL, c("SPY.Open", "SPY.High", "SPY.Low", "SPY.Close", "SPY.Volume", "SPY.Adjusted")) ) - test(19.35, first(xt), xt_first, output="using xts::first: is.xts(x)") - test(19.36, first(xt, n=2L), xt_first2, output="using xts::first: is.xts(x)") + test(19.35, options = c(datatable.verbose=TRUE), first(xt), xt_first, output="using xts::first: is.xts(x)") + test(19.36, options = c(datatable.verbose=TRUE), first(xt, n=2L), xt_first2, output="using xts::first: is.xts(x)") } else { - test(19.21, last(x, n=2L), 2:3, output="using utils::tail: !is.xts(x) & nargs>1 & !'package:xts'%in%search()") - test(19.22, last(y, n=2L), y[2:3], output="using utils::tail: !is.xts(x) & nargs>1 & !'package:xts'%in%search()") - test(19.23, last(x, n=1L), 3L, output="using utils::tail: !is.xts(x) & nargs>1 & !'package:xts'%in%search()") - test(19.24, last(y, n=1L), y[3L], output="using utils::tail: !is.xts(x) & nargs>1 & !'package:xts'%in%search()") - test(19.25, last(xt), error="you should have 'xts' installed already") - test(19.26, last(xt, n=2L), error="you should have 'xts' installed already") - test(19.31, first(x, n=2L), 1:2, output="using utils::head: !is.xts(x) & nargs>1 & !'package:xts'%in%search()") - test(19.32, first(y, n=2L), y[1:2], output="using utils::head: !is.xts(x) & nargs>1 & !'package:xts'%in%search()") - test(19.33, first(x, n=1L), 1L, output="using utils::head: !is.xts(x) & nargs>1 & !'package:xts'%in%search()") - test(19.34, first(y, n=1L), y[1L], output="using utils::head: !is.xts(x) & nargs>1 & !'package:xts'%in%search()") - test(19.35, first(xt), error="you should have 'xts' installed already") - test(19.36, first(xt, n=2L), error="you should have 'xts' installed already") + test(19.21, options = c(datatable.verbose=TRUE), last(x, n=2L), 2:3, output="using utils::tail: !is.xts(x) & nargs>1 & !'package:xts'%in%search()") + test(19.22, options = c(datatable.verbose=TRUE), last(y, n=2L), y[2:3], output="using utils::tail: !is.xts(x) & nargs>1 & !'package:xts'%in%search()") + test(19.23, options = c(datatable.verbose=TRUE), last(x, n=1L), 3L, output="using utils::tail: !is.xts(x) & nargs>1 & !'package:xts'%in%search()") + test(19.24, options = c(datatable.verbose=TRUE), last(y, n=1L), y[3L], output="using utils::tail: !is.xts(x) & nargs>1 & !'package:xts'%in%search()") + test(19.25, options = c(datatable.verbose=TRUE), last(xt), error="you should have 'xts' installed already") + test(19.26, options = c(datatable.verbose=TRUE), last(xt, n=2L), error="you should have 'xts' installed already") + test(19.31, options = c(datatable.verbose=TRUE), first(x, n=2L), 1:2, output="using utils::head: !is.xts(x) & nargs>1 & !'package:xts'%in%search()") + test(19.32, options = c(datatable.verbose=TRUE), first(y, n=2L), y[1:2], output="using utils::head: !is.xts(x) & nargs>1 & !'package:xts'%in%search()") + test(19.33, options = c(datatable.verbose=TRUE), first(x, n=1L), 1L, output="using utils::head: !is.xts(x) & nargs>1 & !'package:xts'%in%search()") + test(19.34, options = c(datatable.verbose=TRUE), first(y, n=1L), y[1L], output="using utils::head: !is.xts(x) & nargs>1 & !'package:xts'%in%search()") + test(19.35, options = c(datatable.verbose=TRUE), first(xt), error="you should have 'xts' installed already") + test(19.36, options = c(datatable.verbose=TRUE), first(xt, n=2L), error="you should have 'xts' installed already") } -test(19.41, last(x), 3L, output="using 'x[[length(x)]]': !is.xts(x) & !nargs>1 & is.null(dim(x))") -test(19.42, last(y), y[3L], output="using 'x[[length(x)]]': !is.xts(x) & !nargs>1 & is.null(dim(x))") -test(19.51, first(x), 1L, output="using 'x[[1L]]': !is.xts(x) & !nargs>1 & is.null(dim(x))") -test(19.52, first(y), y[1L], output="using 'x[[1L]]': !is.xts(x) & !nargs>1 & is.null(dim(x))") -test(19.61, last(df), structure(list(a=2L, b=2L), row.names=2L, class="data.frame"), output="using 'x[nrow(x),]': !is.xts(x) & !nargs>1 & is.data.frame(x)") -test(19.62, last(dt), data.table(a=2L, b=2L), output="using 'x[nrow(x),]': !is.xts(x) & !nargs>1 & is.data.frame(x)") -test(19.71, first(df), structure(list(a=1L, b=3L), row.names=1L, class="data.frame"), output="using 'x[1L,]': !is.xts(x) & !nargs>1 & is.data.frame(x)") -test(19.72, first(dt), data.table(a=1L, b=3L), output="using 'x[1L,]': !is.xts(x) & !nargs>1 & is.data.frame(x)") +test(19.41, options = c(datatable.verbose=TRUE), last(x), 3L, output="using 'x[[length(x)]]': !is.xts(x) & !nargs>1 & is.null(dim(x))") +test(19.42, options = c(datatable.verbose=TRUE), last(y), y[3L], output="using 'x[[length(x)]]': !is.xts(x) & !nargs>1 & is.null(dim(x))") +test(19.51, options = c(datatable.verbose=TRUE), first(x), 1L, output="using 'x[[1L]]': !is.xts(x) & !nargs>1 & is.null(dim(x))") +test(19.52, options = c(datatable.verbose=TRUE), first(y), y[1L], output="using 'x[[1L]]': !is.xts(x) & !nargs>1 & is.null(dim(x))") +test(19.61, options = c(datatable.verbose=TRUE), last(df), structure(list(a=2L, b=2L), row.names=2L, class="data.frame"), output="using 'x[nrow(x),]': !is.xts(x) & !nargs>1 & is.data.frame(x)") +test(19.62, options = c(datatable.verbose=TRUE), last(dt), data.table(a=2L, b=2L), output="using 'x[nrow(x),]': !is.xts(x) & !nargs>1 & is.data.frame(x)") +test(19.71, options = c(datatable.verbose=TRUE), first(df), structure(list(a=1L, b=3L), row.names=1L, class="data.frame"), output="using 'x[1L,]': !is.xts(x) & !nargs>1 & is.data.frame(x)") +test(19.72, options = c(datatable.verbose=TRUE), first(dt), data.table(a=1L, b=3L), output="using 'x[1L,]': !is.xts(x) & !nargs>1 & is.data.frame(x)") # matrix/array utils::tail behavior is likely to change in future R, Michael is more in the topic -test(19.81, last(mx), structure(c(3L, 6L, 9L), .Dim = c(1L, 3L), .Dimnames = list("[3,]", NULL)), output="using utils::tail: !is.xts(x) & !nargs>1 & !is.null(dim(x)) & !is.data.frame(x)") +test(19.81, options = c(datatable.verbose=TRUE), last(mx), structure(c(3L, 6L, 9L), .Dim = c(1L, 3L), .Dimnames = list("[3,]", NULL)), output="using utils::tail: !is.xts(x) & !nargs>1 & !is.null(dim(x)) & !is.data.frame(x)") expected = if (base::getRversion() < "3.7.0") 27L else structure(c(3L, 6L, 9L, 12L, 15L, 18L, 21L, 24L, 27L), .Dim = c(1L, 3L, 3L), .Dimnames = list("[3,]", NULL, NULL)) #4127 -test(19.82, last(ar), expected, output="using utils::tail: !is.xts(x) & !nargs>1 & !is.null(dim(x)) & !is.data.frame(x)") -test(19.91, first(mx), structure(c(1L, 4L, 7L), .Dim = c(1L, 3L)), output="using utils::head: !is.xts(x) & !nargs>1 & !is.null(dim(x)) & !is.data.frame(x)") +test(19.82, options = c(datatable.verbose=TRUE), last(ar), expected, output="using utils::tail: !is.xts(x) & !nargs>1 & !is.null(dim(x)) & !is.data.frame(x)") +test(19.91, options = c(datatable.verbose=TRUE), first(mx), structure(c(1L, 4L, 7L), .Dim = c(1L, 3L)), output="using utils::head: !is.xts(x) & !nargs>1 & !is.null(dim(x)) & !is.data.frame(x)") expected = if (base::getRversion() < "3.7.0") 1L else structure(c(1L, 4L, 7L, 10L, 13L, 16L, 19L, 22L, 25L), .Dim = c(1L, 3L, 3L)) #4127 -test(19.92, first(ar), expected, output="using utils::head: !is.xts(x) & !nargs>1 & !is.null(dim(x)) & !is.data.frame(x)") -options(old) +test(19.92, options = c(datatable.verbose=TRUE), first(ar), expected, output="using utils::head: !is.xts(x) & !nargs>1 & !is.null(dim(x)) & !is.data.frame(x)") if (loaded[["xts"]]) { # was 2133 in tests.Rraw, #5516 # keep.rownames in as.data.table.xts() supports a string, #4232 @@ -671,11 +665,9 @@ if (loaded[["nanotime"]]) { # was 2080.01-05 in tests.Rraw, #5516 n = nanotime(1:4) n[2L] = NA - opt = options(datatable.verbose=TRUE) - test(24.1, between(n, nanotime(2), nanotime(10)), c(FALSE, NA, TRUE, TRUE), output="between parallel processing of integer64") - test(24.2, between(n, nanotime(3), nanotime(10), incbounds=FALSE), c(FALSE, NA, FALSE, TRUE), output="between parallel processing of integer64") - test(24.3, between(n, nanotime(3), nanotime(NA), incbounds=FALSE, NAbounds=NA), c(FALSE, NA, FALSE, NA), output="between parallel processing of integer64") - options(opt) + test(24.1, options = c(datatable.verbose=TRUE), between(n, nanotime(2), nanotime(10)), c(FALSE, NA, TRUE, TRUE), output="between parallel processing of integer64") + test(24.2, options = c(datatable.verbose=TRUE), between(n, nanotime(3), nanotime(10), incbounds=FALSE), c(FALSE, NA, FALSE, TRUE), output="between parallel processing of integer64") + test(24.3, options = c(datatable.verbose=TRUE), between(n, nanotime(3), nanotime(NA), incbounds=FALSE, NAbounds=NA), c(FALSE, NA, FALSE, NA), output="between parallel processing of integer64") test(24.4, between(1:10, nanotime(3), nanotime(6)), error="x is not integer64 but.*Please align classes") test(24.5, between(1:10, 3, nanotime(6)), error="x is not integer64 but.*Please align classes")