Skip to content

Commit 24a306a

Browse files
escape one frollsd tests for valgrind (#7548)
* escape one tests for valgrind * increment skipped count * escape proper one * make test robust to valgrind numerical issues --------- Co-authored-by: Michael Chirico <[email protected]>
1 parent a661e47 commit 24a306a

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

inst/tests/froll.Rraw

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ if (exists("test.data.table", .GlobalEnv, inherits=FALSE)) {
1111

1212
exact_NaN = isTRUE(capabilities()["long.double"]) && identical(as.integer(.Machine$longdouble.digits), 64L)
1313
if (!exact_NaN) {
14-
cat("\n**** Skipping 7 NaN/NA algo='exact' tests because .Machine$longdouble.digits==", .Machine$longdouble.digits, " (!=64); e.g. under valgrind\n\n", sep="")
14+
cat("\n**** Skipping 8 NaN/NA algo='exact' tests because .Machine$longdouble.digits==", .Machine$longdouble.digits, " (!=64); e.g. under valgrind\n\n", sep="")
1515
# for Matt when he runs valgrind it is 53, but 64 when running regular R
1616
# froll.c uses long double and appears to require full long double accuracy in the algo='exact'
1717
}
@@ -1448,9 +1448,12 @@ test(6001.727, frollvar(adaptive=TRUE, c(1:2,NA), c(2,0,2), algo="exact"), c(NA_
14481448
test(6001.728, frollvar(adaptive=TRUE, c(1:2,NA), c(2,0,2), algo="exact", na.rm=TRUE), c(NA_real_,NA_real_,NA_real_))
14491449
test(6001.729, frollvar(adaptive=TRUE, c(1:2,NA), c(2,0,2), algo="exact", na.rm=TRUE, partial=TRUE), c(NA_real_,NA_real_,NA_real_))
14501450
test(6001.730, frollvar(adaptive=TRUE, c(1:2,NA), c(2,0,2), fill=99, algo="exact", na.rm=TRUE), c(99,NA,NA))
1451-
y = c(1e8+2.980232e-8, 1e8, 1e8, 1e8) # CLAMP0 test
1452-
test(6001.731, frollvar(y, 3)[4L], 0)
1453-
test(6001.732, frollsd(y, 3)[4L], 0)
1451+
# numerical stability: we need to guarantee frollvar(x, n) >= 0 for all x, n
1452+
# the exact epsilon here is a bit implementation-dependent (as in #7546), but what's
1453+
# crucial is the output is never negative (or NaN after sqrt() for frollsd).
1454+
y = c(1e8+2.980232e-8, 1e8, 1e8, 1e8)
1455+
test(6001.731, between(frollvar(y, 3)[4L], 0, 1e-7))
1456+
test(6001.732, between(frollsd(y, 3)[4L], 0, 1e-7))
14541457
test(6001.733, frollvar(y, c(3,3,3,3), adaptive=TRUE)[4L], 0)
14551458
test(6001.734, frollsd(y, c(3,3,3,3), adaptive=TRUE)[4L], 0)
14561459
test(6001.740, frollvar(c(1.5,2.5,2,NA), c(3,3)), list(c(NA,NA,0.25,NA), c(NA,NA,0.25,NA)), output="running sequentially, because outer parallelism has been used", options=c(datatable.verbose=TRUE)) # ensure no nested parallelism in rolling functions #7352

0 commit comments

Comments
 (0)