Skip to content

Commit e7199c0

Browse files
Omartech312aidengseaykkarissaben-schwen
authored
Improved verbose messages in rolling functions frolladaptivefun and frollfun (#7733)
* Adding updated files * Updated NEWS.md * Updated test file * Fix test warnings and update output messages * Resolve merge conflict in NEWS.md * Update NEWS.md with new features and fixes * Change to ternary if operator * Change to ternary if operator in froll.c * Removing white space in froll.Rraw * Removing whitespace from NEWS.md * Refactoring rfunNames for copile time definition (in data.table.h) * Removing extra brackets * Declare extern array for roll function names * Reverting changes for rfunStr & adjusting for direct use of rfunNames (defined in froll.c & extern in data.table.h) * Update comments for clarity in frolladaptive.c * Removing spaces * Remove unnecessary newline in frolladaptive.c * Changing NEWS.md message The message now includes our group members as suggested by @ben-schwen * remove trailing comma * Moving message from NEW FEATURES -> Notes moved text stating new change from the NEW FEATURES section to Notes. --------- Co-authored-by: Aiden Seay <aidengseay@gmail.com> Co-authored-by: kkarissa <128569633+kkarissa@users.noreply.github.com> Co-authored-by: Benjamin Schwendinger <52290390+ben-schwen@users.noreply.github.com>
1 parent cd3ef29 commit e7199c0

5 files changed

Lines changed: 59 additions & 46 deletions

File tree

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@
6060

6161
6. Enhanced tests for OpenMP support, detecting incompatibilities such as R-bundled runtime _vs._ newer Xcode and testing for a manually installed runtime from <https://mac.r-project.org/openmp>, [#6622](https://github.com/Rdatatable/data.table/issues/6622). Thanks to @dvg-p4 for initial report and testing, @twitched for the pointers, @tdhock and @aitap for the fix.
6262

63+
7. Verbose outputs from `frolladaptivefun()` and `frollfun()` are now clearer and more user friendly [#7021](https://github.com/Rdatatable/data.table/issues/7021). Thanks to @Omartech312, @aidengseay, @kkarissa, and @heb229 for the implementation, to @ben-schwen for the review, and to @jangorecki for the extensive guidance and review.
64+
6365
## data.table [v1.18.4](https://github.com/Rdatatable/data.table/milestone/45) (6 May 2026)
6466

6567
### BUG FIXES

inst/tests/froll.Rraw

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ test(6000.0671, frollmean(c(1:2,NA,4:10), 4), c(rep(NA_real_, 6), 5.5, 6.5, 7.5,
308308
"frollfunR: 1:",
309309
"frollmeanFast: running for input length 10, window 4, hasnf 0, narm 0",
310310
"frollmeanFast: non-finite values are present in input, skip non-finite unaware attempt and run with extra care for NFs straighaway",
311-
"frollfun: processing fun 0 algo 0 took.*",
311+
"frollfun: processing fun MEAN algo fast took.*",
312312
"frollfunR: processing.*took.*"
313313
))
314314
test(6000.0672, frollmean(c(1:2,NA,4:10), 4, has.nf=FALSE), c(rep(NA_real_, 6), 5.5, 6.5, 7.5, 8.5), output=c(
@@ -317,7 +317,7 @@ test(6000.0672, frollmean(c(1:2,NA,4:10), 4, has.nf=FALSE), c(rep(NA_real_, 6),
317317
"frollfunR: 1:",
318318
"frollmeanFast: running for input length 10, window 4, hasnf -1, narm 0",
319319
"frollmeanFast: non-finite values are present in input, skip non-finite unaware attempt and run with extra care for NFs straighaway",
320-
"frollfun: processing fun 0 algo 0 took.*",
320+
"frollfun: processing fun MEAN algo fast took.*",
321321
"frollfunR: processing.*took.*"
322322
), warning="has.nf=FALSE used but non-finite values are present in input, use default has.nf=NA to avoid this warning")
323323
test(6000.0673, frollmean(c(1:2,NA,4:10), 2, has.nf=FALSE), c(NA, 1.5, NA, NA, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5), output=c(
@@ -326,7 +326,7 @@ test(6000.0673, frollmean(c(1:2,NA,4:10), 2, has.nf=FALSE), c(NA, 1.5, NA, NA, 4
326326
"frollfunR: 1:",
327327
"frollmeanFast: running for input length 10, window 2, hasnf -1, narm 0",
328328
"frollmeanFast: non-finite values are present in input, re-running with extra care for NFs",
329-
"frollfun: processing fun 0 algo 0 took.*",
329+
"frollfun: processing fun MEAN algo fast took.*",
330330
"frollfunR: processing.*took.*"
331331
), warning="has.nf=FALSE used but non-finite values are present in input, use default has.nf=NA to avoid this warning")
332332
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(
@@ -335,7 +335,7 @@ test(6000.0674, frollmean(c(1:2,NA,4:10), 4, align="center"), c(rep(NA_real_, 4)
335335
"frollmeanFast: running for input length 10, window 4, hasnf 0, narm 0",
336336
"frollmeanFast: non-finite values are present in input, skip non-finite unaware attempt and run with extra care for NFs straighaway",
337337
"frollfun: align 0, shift answer by -2",
338-
"frollfun: processing fun 0 algo 0 took.*",
338+
"frollfun: processing fun MEAN algo fast took.*",
339339
"frollfunR: processing.*took.*"
340340
))
341341
options(datatable.verbose=FALSE)
@@ -436,7 +436,7 @@ test(6000.1196, frollmean(c(1:5,NA), 1:6, algo="exact", na.rm=TRUE, adaptive=TRU
436436
"frollfunR: 1:",
437437
"frolladaptivemeanExact: running in parallel for input length 6, hasnf 0, narm 1",
438438
"frolladaptivemeanExact: non-finite values are present in input, re-running with extra care for NFs",
439-
"frolladaptivefun: processing fun 0 algo 1 took.*",
439+
"frolladaptivefun: processing fun MEAN algo exact took.*",
440440
"frollfunR: processing.*took.*"
441441
))
442442
#### exact na.rm=TRUE verbose=TRUE
@@ -446,7 +446,7 @@ test(6000.1197, frollmean(c(1:5,NA), 2, algo="exact", na.rm=TRUE), output=c(
446446
"frollfunR: 1:",
447447
"frollmeanExact: running in parallel for input length 6, window 2, hasnf 0, narm 1",
448448
"frollmeanExact: non-finite values are present in input, re-running with extra care for NFs",
449-
"frollfun: processing fun 0 algo 1 took.*",
449+
"frollfun: processing fun MEAN algo exact took.*",
450450
"frollfunR: processing.*took.*"
451451
))
452452
options(datatable.verbose=FALSE)
@@ -675,81 +675,81 @@ test(6000.171, frollmean(x, n), output=c(
675675
"frollfunR: .*sequentially.*single rolling computation.*",
676676
"frollfunR: 1:",
677677
"frollmeanFast: running for input length 10, window 3, hasnf 0, narm 0",
678-
"frollfun: processing fun 0 algo 0 took.*",
678+
"frollfun: processing fun MEAN algo fast took.*",
679679
"frollfunR: processing.*took.*"))
680680
test(6000.172, frollmean(list(x, x+1), n), output=c(
681681
"frollfunR: allocating memory for results 2x1",
682682
"frollfunR: .*in parallel.*",
683683
"frollfunR: 1:",
684684
"frollmeanFast: running for input length 10, window 3, hasnf 0, narm 0",
685-
"frollfun: processing fun 0 algo 0 took.*",
685+
"frollfun: processing fun MEAN algo fast took.*",
686686
"frollfunR: 2:",
687687
"frollmeanFast: running for input length 10, window 3, hasnf 0, narm 0",
688-
"frollfun: processing fun 0 algo 0 took.*",
688+
"frollfun: processing fun MEAN algo fast took.*",
689689
"frollfunR: processing.*took.*"))
690690
test(6000.173, frollmean(x, c(n, n+1)), output=c(
691691
"frollfunR: allocating memory for results 1x2",
692692
"frollfunR: .*in parallel.*",
693693
"frollfunR: 1:",
694694
"frollmeanFast: running for input length 10, window 3, hasnf 0, narm 0",
695-
"frollfun: processing fun 0 algo 0 took.*",
695+
"frollfun: processing fun MEAN algo fast took.*",
696696
"frollfunR: 2:",
697697
"frollmeanFast: running for input length 10, window 4, hasnf 0, narm 0",
698-
"frollfun: processing fun 0 algo 0 took.*",
698+
"frollfun: processing fun MEAN algo fast took.*",
699699
"frollfunR: processing.*took.*"))
700700
test(6000.174, frollmean(list(x, x+1), c(n, n+1)), output=c(
701701
"frollfunR: allocating memory for results 2x2",
702702
"frollfunR: .*in parallel.*",
703703
"frollfunR: 1:",
704704
"frollmeanFast: running for input length 10, window 3, hasnf 0, narm 0",
705-
"frollfun: processing fun 0 algo 0 took.*",
705+
"frollfun: processing fun MEAN algo fast took.*",
706706
"frollfunR: 2:",
707707
"frollmeanFast: running for input length 10, window 4, hasnf 0, narm 0",
708-
"frollfun: processing fun 0 algo 0 took.*",
708+
"frollfun: processing fun MEAN algo fast took.*",
709709
"frollfunR: 3:",
710710
"frollmeanFast: running for input length 10, window 3, hasnf 0, narm 0",
711-
"frollfun: processing fun 0 algo 0 took.*",
711+
"frollfun: processing fun MEAN algo fast took.*",
712712
"frollfunR: 4:",
713713
"frollmeanFast: running for input length 10, window 4, hasnf 0, narm 0",
714-
"frollfun: processing fun 0 algo 0 took.*",
714+
"frollfun: processing fun MEAN algo fast took.*",
715715
"frollfunR: processing.*took.*"))
716716
test(6000.175, frollmean(x, n, algo="exact"), output=c(
717717
"frollfunR: allocating memory for results 1x1",
718718
"frollfunR: .*algo='exact' is already parallelised.*",
719719
"frollfunR: 1:",
720720
"frollmeanExact: running in parallel for input length 10, window 3, hasnf 0, narm 0",
721-
"frollfun: processing fun 0 algo 1 took.*",
721+
"frollfun: processing fun MEAN algo exact took.*",
722722
"frollfunR: processing.*took.*"))
723723
test(6000.176, frollmean(x, n, align="center"), output=c(
724724
"frollfunR: allocating memory for results 1x1",
725725
"frollfunR: .*sequentially.*single rolling computation.*",
726726
"frollfunR: 1:",
727727
"frollmeanFast: running for input length 10, window 3, hasnf 0, narm 0",
728728
"frollfun: align 0, shift answer by -1",
729-
"frollfun: processing fun 0 algo 0 took.*",
729+
"frollfun: processing fun MEAN algo fast took.*",
730730
"frollfunR: processing.*took.*"))
731731
test(6000.177, frollmean(x, n, align="left"), output=c(
732732
"frollfunR: allocating memory for results 1x1",
733733
"frollfunR: .*sequentially.*single rolling computation.*",
734734
"frollfunR: 1:",
735735
"frollmeanFast: running for input length 10, window 3, hasnf 0, narm 0",
736736
"frollfun: align -1, shift answer by -2",
737-
"frollfun: processing fun 0 algo 0 took.*",
737+
"frollfun: processing fun MEAN algo fast took.*",
738738
"frollfunR: processing.*took.*"))
739739
nn = c(1:4,2:3,1:4)
740740
test(6000.178, frollmean(x, nn, adaptive=TRUE), output=c(
741741
"frollfunR: allocating memory for results 1x1",
742742
"frollfunR: .*sequentially because adaptive.*",
743743
"frollfunR: 1:",
744744
"frolladaptivemeanFast: running for input length 10, hasnf 0, narm 0",
745-
"frolladaptivefun: processing fun 0 algo 0 took.*",
745+
"frolladaptivefun: processing fun MEAN algo fast took.*",
746746
"frollfunR: processing.*took.*"))
747747
test(6000.179, frollmean(x, nn, algo="exact", adaptive=TRUE), output=c(
748748
"frollfunR: allocating memory for results 1x1",
749749
"frollfunR: .*algo='exact' is already parallelised.*",
750750
"frollfunR: 1:",
751751
"frolladaptivemeanExact: running in parallel for input length 10, hasnf 0, narm 0",
752-
"frolladaptivefun: processing fun 0 algo 1 took.*",
752+
"frolladaptivefun: processing fun MEAN algo exact took.*",
753753
"frollfunR: processing.*took.*"))
754754

755755
x[8] = NA
@@ -759,31 +759,31 @@ test(6000.180, frollmean(x, n), output=c(
759759
"frollfunR: 1:",
760760
"frollmeanFast: running for input length 10, window 3, hasnf 0, narm 0",
761761
"frollmeanFast: non-finite values are present in input, re-running with extra care for NFs",
762-
"frollfun: processing fun 0 algo 0 took.*",
762+
"frollfun: processing fun MEAN algo fast took.*",
763763
"frollfunR: processing.*took.*"))
764764
test(6000.181, frollmean(x, n, algo="exact"), output=c(
765765
"frollfunR: allocating memory for results 1x1",
766766
"frollfunR: .*algo='exact' is already parallelised.*",
767767
"frollfunR: 1:",
768768
"frollmeanExact: running in parallel for input length 10, window 3, hasnf 0, narm 0",
769769
"frollmeanExact: non-finite values are present in input, na.rm=FALSE and algo='exact' propagates NFs properply, no need to re-run",
770-
"frollfun: processing fun 0 algo 1 took.*",
770+
"frollfun: processing fun MEAN algo exact took.*",
771771
"frollfunR: processing.*took.*"))
772772
test(6000.182, frollmean(x, nn, adaptive=TRUE), output=c(
773773
"frollfunR: allocating memory for results 1x1",
774774
"frollfunR: .*sequentially because adaptive.*",
775775
"frollfunR: 1:",
776776
"frolladaptivemeanFast: running for input length 10, hasnf 0, narm 0",
777777
"frolladaptivemeanFast: non-finite values are present in input, re-running with extra care for NFs",
778-
"frolladaptivefun: processing fun 0 algo 0 took.*",
778+
"frolladaptivefun: processing fun MEAN algo fast took.*",
779779
"frollfunR: processing.*took.*"))
780780
test(6000.183, frollmean(x, nn, algo="exact", adaptive=TRUE), output=c(
781781
"frollfunR: allocating memory for results 1x1",
782782
"frollfunR: .*algo='exact' is already parallelised.*",
783783
"frollfunR: 1:",
784784
"frolladaptivemeanExact: running in parallel for input length 10, hasnf 0, narm 0",
785785
"frolladaptivemeanExact: non-finite values are present in input, na.rm=FALSE and algo='exact' propagates NFs properply, no need to re-run",
786-
"frolladaptivefun: processing fun 0 algo 1 took.*",
786+
"frolladaptivefun: processing fun MEAN algo exact took.*",
787787
"frollfunR: processing.*took.*"))
788788

789789
d = as.data.table(list(1:10/2, 10:1/4))
@@ -792,24 +792,24 @@ test(6000.184, frollmean(d[,1], 3, algo="exact"), output=c(
792792
"frollfunR: .*algo='exact' is already parallelised.*",
793793
"frollfunR: 1:",
794794
"frollmeanExact: running in parallel for input length 10, window 3, hasnf 0, narm 0",
795-
"frollfun: processing fun 0 algo 1 took.*",
795+
"frollfun: processing fun MEAN algo exact took.*",
796796
"frollfunR: processing.*took.*"
797797
))
798798
test(6000.185, frollmean(d, 3:4, algo="exact"), output=c(
799799
"frollfunR: allocating memory for results 2x2",
800800
"frollfunR: .*sequentially.*algo='exact'.*already parallelised.*",
801801
"frollfunR: 1:",
802802
"frollmeanExact: running in parallel for input length 10, window 3, hasnf 0, narm 0",
803-
"frollfun: processing fun 0 algo 1 took.*",
803+
"frollfun: processing fun MEAN algo exact took.*",
804804
"frollfunR: 2:",
805805
"frollmeanExact: running in parallel for input length 10, window 4, hasnf 0, narm 0",
806-
"frollfun: processing fun 0 algo 1 took.*",
806+
"frollfun: processing fun MEAN algo exact took.*",
807807
"frollfunR: 3:",
808808
"frollmeanExact: running in parallel for input length 10, window 3, hasnf 0, narm 0",
809-
"frollfun: processing fun 0 algo 1 took.*",
809+
"frollfun: processing fun MEAN algo exact took.*",
810810
"frollfunR: 4:",
811811
"frollmeanExact: running in parallel for input length 10, window 4, hasnf 0, narm 0",
812-
"frollfun: processing fun 0 algo 1 took.*",
812+
"frollfun: processing fun MEAN algo exact took.*",
813813
"frollfunR: processing.*took.*"
814814
))
815815
options(datatable.verbose=FALSE)
@@ -861,9 +861,9 @@ options(datatable.verbose=FALSE)
861861

862862
## frollmax adaptive
863863
options(datatable.verbose=TRUE) ## adaptive frollmax no fast algo
864-
test(6000.3, frollmax(1:4, c(2,2,2,2), adaptive=TRUE), output="frolladaptivefun: algo 0 not implemented, fall back to 1")
865-
test(6000.3001, frollmax(1:4, c(2,2,2,2), algo="fast", adaptive=TRUE), output="frolladaptivefun: algo 0 not implemented, fall back to 1")
866-
test(6000.3002, frollmax(1:4, c(2,2,2,2), algo="exact", adaptive=TRUE), notOutput="frolladaptivefun: algo 0 not implemented, fall back to 1")
864+
test(6000.3, frollmax(1:4, c(2,2,2,2), adaptive=TRUE), output="frolladaptivefun: algo fast not implemented, fall back to exact")
865+
test(6000.3001, frollmax(1:4, c(2,2,2,2), algo="fast", adaptive=TRUE), output="frolladaptivefun: algo fast not implemented, fall back to exact")
866+
test(6000.3002, frollmax(1:4, c(2,2,2,2), algo="exact", adaptive=TRUE), notOutput="frolladaptivefun: algo fast not implemented, fall back to exact")
867867
options(datatable.verbose=FALSE)
868868
n = c(3,2,2,4,2,1,4,8)
869869
x = c(7,2,3,6,3,2,6,6) # no NA
@@ -1022,9 +1022,9 @@ test(6000.564, frollapply(FUN=mean, 1:3, list(c(0,-1,1)), adaptive=TRUE), error=
10221022

10231023
## frollmin adaptive
10241024
options(datatable.verbose=TRUE) ## adaptive frollmin no fast algo
1025-
test(6000.6, frollmin(1:4, c(2,2,2,2), adaptive=TRUE), output="frolladaptivefun: algo 0 not implemented, fall back to 1")
1026-
test(6000.6001, frollmin(1:4, c(2,2,2,2), algo="fast", adaptive=TRUE), output="frolladaptivefun: algo 0 not implemented, fall back to 1")
1027-
test(6000.6002, frollmin(1:4, c(2,2,2,2), algo="exact", adaptive=TRUE), notOutput="frolladaptivefun: algo 0 not implemented, fall back to 1")
1025+
test(6000.6, frollmin(1:4, c(2,2,2,2), adaptive=TRUE), output="frolladaptivefun: algo fast not implemented, fall back to exact")
1026+
test(6000.6001, frollmin(1:4, c(2,2,2,2), algo="fast", adaptive=TRUE), output="frolladaptivefun: algo fast not implemented, fall back to exact")
1027+
test(6000.6002, frollmin(1:4, c(2,2,2,2), algo="exact", adaptive=TRUE), notOutput="frolladaptivefun: algo fast not implemented, fall back to exact")
10281028
options(datatable.verbose=FALSE)
10291029
n = c(3,2,2,4,2,1,4,8)
10301030
x = c(7,2,3,6,3,2,6,6) # no NA
@@ -1200,7 +1200,7 @@ test(6000.931, frollprod(1:3, 2), c(NA, 2, 6), output="frollprodFast: running fo
12001200
test(6000.932, frollprod(1:3, 2, align="left"), c(2, 6, NA), output="frollfun: align")
12011201
test(6000.933, frollprod(c(1,2,NA), 2), c(NA, 2, NA), output="non-finite values are present in input, re-running with extra care for NFs")
12021202
test(6000.934, frollprod(c(NA,2,3), 2), c(NA, NA, 6), output="non-finite values are present in input, skip non-finite inaware attempt and run with extra care for NFs straighaway")
1203-
test(6000.935, frollprod(1:3, c(2,2,2), adaptive=TRUE), c(NA, 2, 6), output="algo 0 not implemented, fall back to 1")
1203+
test(6000.935, frollprod(1:3, c(2,2,2), adaptive=TRUE), c(NA, 2, 6), output="algo fast not implemented, fall back to exact")
12041204
test(6000.936, frollprod(c(NA,2,3), c(2,2,2), adaptive=TRUE), c(NA, NA, 6), output="non-finite values are present in input, na.rm=FALSE and algo='exact' propagates NFs properply, no need to re-run")
12051205
options(datatable.verbose=FALSE)
12061206
# floating point overflow
@@ -1433,7 +1433,7 @@ test(6001.715, frollvar(1:3, 0, algo="exact"), c(NA_real_,NA_real_,NA_real_), op
14331433
test(6001.716, frollvar(c(1:2,NA), 0, algo="exact"), c(NA_real_,NA_real_,NA_real_))
14341434
test(6001.717, frollvar(c(1:2,NA), 0, algo="exact", na.rm=TRUE), c(NA_real_,NA_real_,NA_real_))
14351435
test(6001.718, frollvar(c(1:2,NA), 2), c(NA,0.5,NA), options=c("datatable.verbose"=TRUE), output="redirecting to frollvarExact")
1436-
test(6001.721, frollvar(adaptive=TRUE, 1:3, c(2,0,2)), c(NA,NA,0.5), options=c("datatable.verbose"=TRUE), output="not implemented, fall back to")
1436+
test(6001.721, frollvar(adaptive=TRUE, 1:3, c(2,0,2)), c(NA,NA,0.5), options=c("datatable.verbose"=TRUE), output="algo fast not implemented, fall back to exact")
14371437
test(6001.722, frollvar(adaptive=TRUE, 1:3, c(2,0,2), fill=99), c(99,NA,0.5))
14381438
test(6001.723, frollvar(adaptive=TRUE, c(1:2,NA), c(2,0,2)), c(NA_real_,NA_real_,NA_real_))
14391439
test(6001.724, frollvar(adaptive=TRUE, c(1:2,NA), c(2,0,2), na.rm=TRUE), c(NA_real_,NA_real_,NA_real_))
@@ -1492,7 +1492,7 @@ test(6001.8194, frollsd(c(NA,2:3), 2, has.nf=FALSE), c(NA,NA,sqrt(0.5)), warning
14921492
test(6001.8195, frollsd(c(NA,2:3), 2), c(NA,NA,sqrt(0.5)), options=c("datatable.verbose"=TRUE), output="skip non-finite inaware attempt and run with extra care")
14931493
test(6001.8196, frollsd(c(NA,2:3), 2, has.nf=FALSE, algo="exact"), c(NA,NA,sqrt(0.5)), warning="used but non-finite values are present in input")
14941494
test(6001.8197, frollsd(c(NA,2:3), 2, algo="exact", na.rm=TRUE), c(NA,NA,sqrt(0.5)), options=c("datatable.verbose"=TRUE), output="re-running with extra care for NF")
1495-
test(6001.8201, frollsd(adaptive=TRUE, 1:3, c(2,2,2)), c(NA,sqrt(0.5),sqrt(0.5)), options=c("datatable.verbose"=TRUE), output="frolladaptivefun: algo 0 not implemented, fall back to 1")
1495+
test(6001.8201, frollsd(adaptive=TRUE, 1:3, c(2,2,2)), c(NA,sqrt(0.5),sqrt(0.5)), options=c("datatable.verbose"=TRUE), output="frolladaptivefun: algo fast not implemented, fall back to exact")
14961496
test(6001.8202, frollsd(adaptive=TRUE, 1:3, c(2,2,2)), c(NA,sqrt(0.5),sqrt(0.5)), options=c("datatable.verbose"=TRUE), output="frolladaptivesdExact: calling sqrt(frolladaptivevarExact(...))")
14971497
test(6001.821, frollsd(adaptive=TRUE, 1:3, c(2,0,2)), c(NA,NA,sqrt(0.5)))
14981498
test(6001.822, frollsd(adaptive=TRUE, 1:3, c(2,0,2), fill=99), c(99,NA,sqrt(0.5)))

src/data.table.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ typedef enum { // adding rolling functions here and in frollfunR in frollR.c
259259
VAR = 6,
260260
SD = 7
261261
} rollfun_t;
262+
extern const char *const rfunNames[]; // Array of roll function names defined in froll.c
262263
// froll.c
263264
void frollfun(rollfun_t rfun, unsigned int algo, const double *x, uint64_t nx, ans_t *ans, int k, int align, double fill, bool narm, int hasnf, bool verbose, bool par);
264265
void frollmeanFast(const double *x, uint64_t nx, ans_t *ans, int k, double fill, bool narm, int hasnf, bool verbose);

src/froll.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#include "data.table.h"
22

3+
const char *const rfunNames[] = {
4+
"MEAN", "SUM", "MAX", "MIN", "PROD", "MEDIAN", "VAR", "SD"}; //constant definition of froll functions
35
/*
46
OpenMP is used here to parallelize the loops in most of the
57
implementations of rolling functions.
@@ -104,7 +106,7 @@ void frollfun(rollfun_t rfun, unsigned int algo, const double *x, uint64_t nx, a
104106
}
105107
}
106108
if (verbose)
107-
snprintf(end(ans->message[0]), 500, _("%s: processing fun %d algo %u took %.3fs\n"), __func__, rfun, algo, omp_get_wtime()-tic);
109+
snprintf(end(ans->message[0]), 500, _("%s: processing fun %s algo %s took %.3fs\n"), __func__, rfunNames[rfun], (algo == 0) ? "fast" : "exact", omp_get_wtime()-tic);
108110
}
109111

110112
#undef SUM_WINDOW_STEP_FRONT

0 commit comments

Comments
 (0)