Skip to content

Commit d3fd47e

Browse files
committed
Merge branch 'master' into froll-prod2
2 parents 347e848 + c5e8152 commit d3fd47e

File tree

15 files changed

+1043
-57
lines changed

15 files changed

+1043
-57
lines changed

.github/workflows/pkgup.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ jobs:
3939
Rscript -e 'stopifnot(file.copy("DESCRIPTION", file.path(tdir<-tempdir(), "PACKAGES"))); db<-available.packages(paste0("file://", tdir)); deps<-setdiff(tools::package_dependencies(read.dcf("DESCRIPTION", fields="Package")[[1L]], db, which="most")[[1L]], installed.packages(priority="high")[,"Package"]); if (length(deps)) { ap<-available.packages()[,"Version"]; ap<-ap[names(ap) %in% deps]; if (!all(deps%in%names(ap))) stop("dependencies are not avaiable in repository: ",paste(setdiff(deps, names(ap)), collapse=", ")); ip<-installed.packages()[,"Version"]; ip<-ip[names(ip) %in% deps]; pkgs<-ap[deps]>ip[deps]; install.packages(names(pkgs[pkgs|is.na(pkgs)]), INSTALL_opts="--html") }'
4040
- name: build
4141
run: |
42-
sed -i "0,/^Version: [0-9.]\+$/s//&-$(TZ=UTC git log -1 --format=%ct)/" ./DESCRIPTION
4342
echo "Revision:" $GITHUB_SHA >> ./DESCRIPTION
4443
R CMD build .
4544
- name: check

.gitlab-ci.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,6 @@ build:
7777
- rm -r bus
7878
script:
7979
- sed -i '/^[[:space:]]*$/d' ./DESCRIPTION ## make last line end abruptly; i.e. without a final \n
80-
- |
81-
sed -i "0,/^Version: [0-9.]\+$/s//&-$(date -d "$CI_COMMIT_TIMESTAMP" +%s)/" ./DESCRIPTION
8280
- echo "Revision:" $CI_COMMIT_SHA >> ./DESCRIPTION
8381
- R CMD build .
8482
- mkdir -p bus/$CI_JOB_NAME/
@@ -184,7 +182,7 @@ test-lin-dev-gcc-strict-cran:
184182
- R CMD check --as-cran $(ls -1t data.table_*.tar.gz | head -n 1)
185183
- (! grep "warning:" data.table.Rcheck/00install.out)
186184
- >-
187-
Rscript -e 'l=tail(readLines("data.table.Rcheck/00check.log"), 1L); notes<-"Status: 3 NOTEs"; if (!identical(l, notes)) stop("Last line of ", shQuote("00check.log"), " is not ", shQuote(notes), " (size of tarball, non-API calls, V8 package) but ", shQuote(l)) else q("no")'
185+
Rscript -e 'l=tail(readLines("data.table.Rcheck/00check.log"), 1L); notes<-"Status: 2 NOTEs"; if (!identical(l, notes)) stop("Last line of ", shQuote("00check.log"), " is not ", shQuote(notes), " (non-API calls, V8 package) but ", shQuote(l)) else q("no")'
188186
189187
## R-devel on Linux clang
190188
# R compiled with clang, flags removed: -flto=auto -fopenmp
@@ -207,7 +205,7 @@ test-lin-dev-clang-cran:
207205
- R CMD check --as-cran $(ls -1t data.table_*.tar.gz | head -n 1)
208206
- (! grep "warning:" data.table.Rcheck/00install.out)
209207
- >-
210-
Rscript -e 'l=tail(readLines("data.table.Rcheck/00check.log"), 1L); notes<-"Status: 3 NOTEs"; if (!identical(l, notes)) stop("Last line of ", shQuote("00check.log"), " is not ", shQuote(notes), " (size of tarball, non-API calls, V8 package) but ", shQuote(l)) else q("no")'
208+
Rscript -e 'l=tail(readLines("data.table.Rcheck/00check.log"), 1L); notes<-"Status: 2 NOTEs"; if (!identical(l, notes)) stop("Last line of ", shQuote("00check.log"), " is not ", shQuote(notes), " (non-API calls, V8 package) but ", shQuote(l)) else q("no")'
211209
212210
# stated dependency on R
213211
test-lin-ancient-cran:

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ export(frollsum)
5757
export(frollmax)
5858
export(frollmin)
5959
export(frollprod)
60+
export(frollmedian)
6061
export(frollapply)
6162
export(frolladapt)
6263
export(nafill)

NEWS.md

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,51 @@
246246
#9: 2025-09-22 9 8 9.0
247247
```
248248

249-
19. New rolling functions, `frollmin` and `frollprod`, have been implemented, towards [#2778](https://github.com/Rdatatable/data.table/issues/2778). Thanks to @jangorecki for implementation.
249+
19. New rolling functions: `frollmin`, `frollprod` and `frollmedian`, have been implemented, towards [#2778](https://github.com/Rdatatable/data.table/issues/2778). Thanks to @jangorecki for implementation. Implementation of rolling median is based on a novel algorithm "sort-median" described by [@suomela](https://github.com/suomela) in his 2014 paper [Median Filtering is Equivalent to Sorting](https://arxiv.org/abs/1406.1717). "sort-median" scales very well, not only for size of input vector but also for size of rolling window.
250+
```r
251+
rollmedian = function(x, n) {
252+
ans = rep(NA_real_, nx<-length(x))
253+
if (n<=nx) for (i in n:nx) ans[i] = median(x[(i-n+1L):(i)])
254+
ans
255+
}
256+
library(data.table)
257+
setDTthreads(8)
258+
set.seed(108)
259+
x = rnorm(1e5)
260+
261+
n = 100
262+
system.time(rollmedian(x, n))
263+
# user system elapsed
264+
# 2.049 0.001 2.051
265+
system.time(frollapply(x, n, median, simplify=unlist))
266+
# user system elapsed
267+
# 3.071 0.223 0.436
268+
system.time(frollmedian(x, n))
269+
# user system elapsed
270+
# 0.013 0.000 0.004
271+
272+
n = 1000
273+
system.time(rollmedian(x, n))
274+
# user system elapsed
275+
# 3.496 0.009 3.507
276+
system.time(frollapply(x, n, median, simplify=unlist))
277+
# user system elapsed
278+
# 4.552 0.307 0.632
279+
system.time(frollmedian(x, n))
280+
# user system elapsed
281+
# 0.015 0.000 0.004
282+
283+
n = 10000
284+
system.time(rollmedian(x, n))
285+
# user system elapsed
286+
# 16.350 0.025 16.382
287+
system.time(frollapply(x, n, median, simplify=unlist))
288+
# user system elapsed
289+
# 14.865 0.722 2.267
290+
system.time(frollmedian(x, n))
291+
# user system elapsed
292+
# 0.028 0.000 0.005
293+
```
250294

251295
### BUG FIXES
252296

R/froll.R

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,3 +213,6 @@ frollmin = function(x, n, fill=NA, algo=c("fast","exact"), align=c("right","left
213213
frollprod = function(x, n, fill=NA, algo=c("fast","exact"), align=c("right","left","center"), na.rm=FALSE, has.nf=NA, adaptive=FALSE, partial=FALSE, give.names=FALSE, hasNA) {
214214
froll(fun="prod", x=x, n=n, fill=fill, algo=algo, align=align, na.rm=na.rm, has.nf=has.nf, adaptive=adaptive, partial=partial, hasNA=hasNA, give.names=give.names)
215215
}
216+
frollmedian = function(x, n, fill=NA, algo=c("fast","exact"), align=c("right","left","center"), na.rm=FALSE, has.nf=NA, adaptive=FALSE, partial=FALSE, give.names=FALSE, hasNA) {
217+
froll(fun="median", x=x, n=n, fill=fill, algo=algo, align=align, na.rm=na.rm, has.nf=has.nf, adaptive=adaptive, partial=partial, hasNA=hasNA, give.names=give.names)
218+
}

R/onLoad.R

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@
1414
# check when installed package is loaded but skip when developing the package with cc()
1515
dllV = if (is.loaded("CdllVersion",PACKAGE="data_table")) .Call(CdllVersion) else "before 1.12.0"
1616
RV = as.character(packageVersion("data.table"))
17-
if (sum(.dots <- charToRaw(RV) == charToRaw(".")) > 2L) {
18-
## trim dev version suffix 1.17.99-1234567890, note that base:::package_version turns `-` into `.` #7339
19-
RV = substring(RV, 1L, which(.dots)[3L]-1L)
20-
}
2117
if (dllV != RV) {
2218
dll = if (.Platform$OS.type=="windows") "dll" else "so"
2319
# https://bugs.r-project.org/bugzilla/show_bug.cgi?id=17478

0 commit comments

Comments
 (0)