Skip to content

Commit 3ac805b

Browse files
Allow logical columns in frollapply() again (#7504)
* include LGLSXP * some tests
1 parent dc1dbe9 commit 3ac805b

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

inst/tests/froll.Rraw

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1254,14 +1254,17 @@ test(6001.181, frollapply(FUN=mean, 1:3, 0), c(NaN,NaN,NaN))
12541254
test(6001.182, frollapply(FUN=mean, 1:3, 0, fill=99), c(NaN,NaN,NaN))
12551255
test(6001.183, frollapply(FUN=mean, c(1:2,NA), 0), c(NaN,NaN,NaN))
12561256
test(6001.184, frollapply(FUN=mean, c(1:2,NA), 0, na.rm=TRUE), c(NaN,NaN,NaN))
1257+
test(6001.185, frollapply(FUN=mean, c(FALSE, TRUE, TRUE), 0), c(NaN,NaN,NaN))
12571258
test(6001.1910, frollapply(FUN=mean, adaptive=TRUE, 1:3, c(2,0,2)), c(NA,NaN,2.5))
12581259
test(6001.1911, frollapply(FUN=mean, adaptive=TRUE, list(1:3,2:4), c(2,0,2)), list(c(NA, NaN, 2.5), c(NA, NaN, 3.5)))
12591260
test(6001.1912, frollapply(FUN=mean, adaptive=TRUE, 1:3, list(c(2,0,2), c(0,2,0))), list(c(NA,NaN,2.5), c(NaN,1.5,NaN)))
12601261
test(6001.1913, frollapply(FUN=mean, adaptive=TRUE, list(1:3,2:4), list(c(2,0,2), c(0,2,0))), list(c(NA,NaN,2.5), c(NaN,1.5,NaN), c(NA,NaN,3.5), c(NaN,2.5,NaN)))
1262+
test(6001.1915, frollapply(FUN=mean, adaptive=TRUE, c(FALSE, TRUE, TRUE), c(2,0,2)), c(NA,NaN,1))
12611263
test(6001.192, frollapply(FUN=mean, adaptive=TRUE, 1:3, c(2,0,2), fill=99), c(99,NaN,2.5))
12621264
test(6001.193, frollapply(FUN=mean, adaptive=TRUE, c(1:2,NA), c(2,0,2)), c(NA,NaN,NA))
12631265
test(6001.194, frollapply(FUN=mean, adaptive=TRUE, c(1:2,NA), c(2,0,2), na.rm=TRUE), c(NA,NaN,2))
12641266
test(6001.195, frollapply(FUN=mean, adaptive=TRUE, c(1:2,NA_real_), c(2,0,2), na.rm=TRUE, partial=TRUE), c(1,NaN,2))
1267+
test(6001.196, frollapply(FUN=mean, adaptive=TRUE, c(FALSE, TRUE, TRUE), c(2,0,2), fill=99), c(99,NaN,1))
12651268

12661269
test(6001.211, frollsum(1:3, 0), c(0,0,0), options=c("datatable.verbose"=TRUE), output="window width of size 0")
12671270
test(6001.212, frollsum(1:3, 0, fill=99), c(0,0,0))
@@ -1284,14 +1287,20 @@ test(6001.281, frollapply(FUN=sum, as.numeric(1:3), 0), c(0,0,0))
12841287
test(6001.282, frollapply(FUN=sum, as.numeric(1:3), 0, fill=99), c(0,0,0))
12851288
test(6001.283, frollapply(FUN=sum, c(1:2,NA_real_), 0), c(0,0,0))
12861289
test(6001.284, frollapply(FUN=sum, c(1:2,NA_real_), 0, na.rm=TRUE), c(0,0,0))
1290+
test(6001.285, frollapply(FUN=sum, c(FALSE, TRUE, TRUE), 0), c(0L,0L,0L))
1291+
test(6001.286, frollapply(FUN=sum, 1:3, 0), c(0L,0L,0L))
12871292
test(6001.2910, frollapply(FUN=sum, adaptive=TRUE, as.numeric(1:3), c(2,0,2)), c(NA,0,5))
12881293
test(6001.2911, frollapply(FUN=sum, adaptive=TRUE, list(as.numeric(1:3), as.numeric(2:4)), c(2,0,2)), list(c(NA,0,5), c(NA,0,7)))
12891294
test(6001.2912, frollapply(FUN=sum, adaptive=TRUE, as.numeric(1:3), list(c(2,0,2), c(0,2,0))), list(c(NA,0,5), c(0,3,0)))
12901295
test(6001.2913, frollapply(FUN=sum, adaptive=TRUE, list(as.numeric(1:3), as.numeric(2:4)), list(c(2,0,2), c(0,2,0))), list(c(NA,0,5), c(0,3,0), c(NA,0,7), c(0,5,0)))
1296+
test(6001.2914, frollapply(FUN=sum, adaptive=TRUE, c(FALSE, TRUE, TRUE), c(2,0,2)), c(NA,0L,2L))
1297+
test(6001.2915, frollapply(FUN=sum, adaptive=TRUE, 1:3, c(2,0,2)), c(NA,0L,5L))
12911298
test(6001.292, frollapply(FUN=sum, adaptive=TRUE, as.numeric(1:3), c(2,0,2), fill=99), c(99,0,5))
12921299
test(6001.293, frollapply(FUN=sum, adaptive=TRUE, c(1:2,NA_real_), c(2,0,2)), c(NA,0,NA))
12931300
test(6001.294, frollapply(FUN=sum, adaptive=TRUE, c(1:2,NA_real_), c(2,0,2), na.rm=TRUE), c(NA,0,2))
12941301
test(6001.295, frollapply(FUN=sum, adaptive=TRUE, c(1:2,NA_real_), c(2,0,2), na.rm=TRUE, partial=TRUE), c(1,0,2))
1302+
test(6001.296, frollapply(FUN=sum, adaptive=TRUE, c(FALSE, TRUE, TRUE), c(2,0,2), fill=1L), c(1L,0L,2L))
1303+
test(6001.297, frollapply(FUN=sum, adaptive=TRUE, 1:3, c(2,0,2), fill=99), c(99L,0L,5L))
12951304

12961305
test(6001.311, frollmax(1:3, 0), c(-Inf,-Inf,-Inf), options=c("datatable.verbose"=TRUE), output="window width of size 0")
12971306
test(6001.312, frollmax(1:3, 0, fill=99), c(-Inf,-Inf,-Inf))

src/frollapply.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
static inline void memcpy_sexp(SEXP dest, size_t offset, SEXP src, int count) {
44
switch (TYPEOF(dest)) {
5-
case INTSXP: {
5+
case LGLSXP: case INTSXP: {
66
memcpy(INTEGER(dest), INTEGER_RO(src) + offset, count * sizeof(int));
77
} break;
88
case REALSXP: {

0 commit comments

Comments
 (0)