Skip to content

Commit 2c54ad2

Browse files
committed
fix codecov
1 parent e12425f commit 2c54ad2

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

R/frollapply.R

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ frollapply = function(X, N, FUN, ..., by.column=TRUE, fill=NA, align=c("right","
171171
nn = length(N)
172172
nnam = names(N)
173173
} else
174-
stopf("'N' must be integer vector or list of integer vectors")
174+
stopf("n must be an integer vector or list of an integer vectors")
175175
}
176176
## partial
177177
if (partial) {
@@ -290,12 +290,14 @@ frollapply = function(X, N, FUN, ..., by.column=TRUE, fill=NA, align=c("right","
290290
jobs = vector("integer", ths)
291291
for (th in seq_len(ths)) {
292292
jobs[th] = parallel::mcparallel({
293+
# nocov start ## fork processes seem not to be tracked by codecov
293294
setDTthreads(1L) ## disable nested parallelism
294295
lapply(ii[[th]], ## loops over indexes for that thread
295296
FUN = tight, ## handles adaptive and by.column
296297
dest = cpy(w), ## allocate own window for each thread
297298
src = thisx, ## full input
298299
n = thisn) ## scalar or in adaptive case a vector
300+
# nocov end
299301
})[["pid"]]
300302
}
301303
} else { ## windows || getDTthreads()==1L

inst/tests/froll.Rraw

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1291,6 +1291,12 @@ test(6010.545, frollapply(1:2, 2, sum, simplify=NA), error="must be TRUE or FALS
12911291
test(6010.561, frollapply(x=1:2, N=2, FUN=sum), c(NA,3L), warning="'x' is deprecated in frollapply, use 'X' instead")
12921292
test(6010.562, frollapply(X=1:2, n=2, FUN=sum), c(NA,3L), warning="'n' is deprecated in frollapply, use 'N' instead")
12931293
test(6010.563, frollapply(x=1:2, n=2, FUN=sum), c(NA,3L), warning=c("'x' is deprecated in frollapply, use 'X' instead","'n' is deprecated in frollapply, use 'N' instead"))
1294+
test(6010.564, frollapply(1:2, c("a","a"), length, adaptive=TRUE), error="n must be an integer vector or list of an integer vectors")
1295+
test(6010.565, frollapply(1:2, list(c("a","a")), length, adaptive=TRUE), error="n must be an integer vector or list of an integer vectors")
1296+
test(6010.566, frollapply(1:2, 2, length, by.column=FALSE), error="frollapply by.column=FALSE requires 'X' argument to be")
1297+
test(6010.567, frollapply(list(1:2, list(c("a","b"))), 2, length, by.column=FALSE), error="frollapply by.column=FALSE got list in 'X' but it is not valid one")
1298+
test(6010.568, frollapply(list(data.frame(x=1:2), data.frame(x=I(list(1:2)))), 2, length, by.column=FALSE), error="not all columns of data.frames/data.tables are atomic")
1299+
test(6010.569, frollapply(list(1:2, NULL), 2, length), error="argument to be atomic or a list of those")
12941300

12951301
## by.column
12961302
x = data.table(v1=1:5, v2=2:6/2)
@@ -1300,6 +1306,9 @@ test(6010.603, frollapply(x, 3, FUN=tail, 1L, by.column=FALSE, partial=TRUE), x)
13001306
test(6010.604, frollapply(x, 3, dim, by.column=FALSE, partial=TRUE), data.table(V1=c(1:3,3L,3L), V2=c(2L,2L,2L,2L,2L))) ## fill is not used in partial
13011307
test(6010.605, frollapply(x, 3, function(x) setNames(dim(x), c("rows","cols")), by.column=FALSE, partial=TRUE), data.table(rows=c(1:3,3L,3L), cols=c(2L,2L,2L,2L,2L)))
13021308
test(6010.606, frollapply(x, rep(3,5), dim, by.column=FALSE, fill=c(rows=NA_integer_, cols=NA_integer_), adaptive=TRUE, align="left"), data.table(rows=c(3L,3L,3L,NA,NA), cols=c(2L,2L,2L,NA,NA)))
1309+
test(6010.6061, frollapply(as.data.frame(x), rep(3,5), dim, by.column=FALSE, fill=c(rows=NA_integer_, cols=NA_integer_), adaptive=TRUE, align="left", simplify=function(x) as.data.frame(do.call("rbind",x))), data.frame(rows=c(3L,3L,3L,NA,NA), cols=c(2L,2L,2L,NA,NA)))
1310+
test(6010.6062, frollapply(as.list(x), rep(3,5), function(x) c(length(x[[1L]]), length(x)), by.column=FALSE, fill=c(rows=NA_integer_, cols=NA_integer_), adaptive=TRUE, align="left", simplify=function(x) setNames(transpose(x), c("rows","cols"))), list(rows=c(3L,3L,3L,NA,NA), cols=c(2L,2L,2L,NA,NA)))
1311+
13031312
#### empty input
13041313
test(6010.607, frollapply(list(), 3, identity, by.column=FALSE), list())
13051314
test(6010.608, frollapply(list(numeric(), numeric()), 3, identity, by.column=FALSE), list())
@@ -1352,7 +1361,7 @@ test(6010.653, y = ans, x = lapply(
13521361
))
13531362
rm(X, ans, n)
13541363

1355-
## simplify
1364+
## simplify simplifyList
13561365
test(6010.701, frollapply(1:5, 2, sum), c(NA,3L,5L,7L,9L))
13571366
test(6010.702, frollapply(1:5, 2, sum, simplify=unlist), c(NA,3L,5L,7L,9L))
13581367
test(6010.703, frollapply(1:5, 2, sum, simplify=FALSE), list(NA,3L,5L,7L,9L))
@@ -1364,6 +1373,9 @@ test(6010.708, frollapply(1:5, 2, range, fill=c(min=NA_integer_, max=NA_integer_
13641373
test(6010.709, frollapply(1:5, 2, function(x) as.list(range(x)), fill=list(min=NA_integer_, max=NA_integer_)), data.table(min=c(NA,1:4), max=c(NA,2:5)))
13651374
test(6010.710, frollapply(1:5, 2, function(x) as.list(range(x)), fill=list(min=NA_integer_, max=NA_integer_), simplify=rbindlist), data.table(min=c(NA,1:4), max=c(NA,2:5)))
13661375
test(6010.711, frollapply(1:5, 2, function(x) as.list(range(x)), fill=list(NA_integer_, NA_integer_), simplify=FALSE), list(list(NA_integer_, NA_integer_), as.list(1:2), as.list(2:3), as.list(3:4), as.list(4:5)))
1376+
test(6010.712, as.null(frollapply(1:3, 1, function(x) if (x==1L) sum else if (x==2L) mean else `[`, simplify=TRUE)), NULL) ## as.null as we are only interested in codecov here
1377+
test(6010.713, as.null(frollapply(1:3, 1, function(x) `[`, simplify = TRUE)), NULL) ## as.null as we are only interested in codecov here
1378+
13671379
#### fixing .internal.selfref
13681380
use.fork = .Platform$OS.type!="windows" && getDTthreads()>1L
13691381
if (use.fork) {

src/frollapply.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ SEXP memcpyVector(SEXP dest, SEXP src, SEXP offset, SEXP size) {
3939
MEMCPY
4040
return dest;
4141
}
42+
// # nocov start ## does not seem to be reported to codecov most likely due to running in a fork, I manually debugged that the is being called from R when running froll.Rraw
4243
SEXP memcpyDT(SEXP dest, SEXP src, SEXP offset, SEXP size) {
4344
size_t o = INTEGER(offset)[0] - INTEGER(size)[0];
4445
int ncol = LENGTH(dest), nrow = LENGTH(VECTOR_ELT(dest, 0));
@@ -50,6 +51,7 @@ SEXP memcpyDT(SEXP dest, SEXP src, SEXP offset, SEXP size) {
5051
}
5152
return dest;
5253
}
54+
// # nocov end
5355

5456
SEXP memcpyVectoradaptive(SEXP dest, SEXP src, SEXP offset, SEXP size) {
5557
size_t oi = INTEGER(offset)[0];
@@ -60,6 +62,7 @@ SEXP memcpyVectoradaptive(SEXP dest, SEXP src, SEXP offset, SEXP size) {
6062
MEMCPY
6163
return dest;
6264
}
65+
// # nocov start ## does not seem to be reported to codecov most likely due to running in a fork, I manually debugged that the is being called from R when running froll.Rraw
6366
SEXP memcpyDTadaptive(SEXP dest, SEXP src, SEXP offset, SEXP size) {
6467
size_t oi = INTEGER(offset)[0];
6568
int nrow = INTEGER(size)[oi-1];
@@ -74,6 +77,7 @@ SEXP memcpyDTadaptive(SEXP dest, SEXP src, SEXP offset, SEXP size) {
7477
}
7578
return dest;
7679
}
80+
// # nocov end
7781

7882
// needed in adaptive=TRUE
7983
SEXP setgrowable(SEXP x) {

0 commit comments

Comments
 (0)