Skip to content

Commit eb8056c

Browse files
committed
rename levels argument to optimization
1 parent 25a7e2e commit eb8056c

File tree

5 files changed

+280
-280
lines changed

5 files changed

+280
-280
lines changed

R/test.data.table.R

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -361,25 +361,25 @@ gc_mem = function() {
361361
# nocov end
362362
}
363363

364-
test = function(num,x,y=TRUE,error=NULL,warning=NULL,message=NULL,output=NULL,notOutput=NULL,ignore.warning=NULL,options=NULL,env=NULL,levels=NULL) {
365-
# if levels is provided, test across multiple optimization levels
366-
if (!is.null(levels)) {
364+
test = function(num,x,y=TRUE,error=NULL,warning=NULL,message=NULL,output=NULL,notOutput=NULL,ignore.warning=NULL,options=NULL,env=NULL,optimization=NULL) {
365+
# if optimization is provided, test across multiple optimization levels
366+
if (!is.null(optimization)) {
367367
cl = match.call()
368-
cl$levels = NULL # Remove levels from the recursive call
368+
cl$optimization = NULL # Remove optimization levels from the recursive call
369369

370370
vector_params = c("error", "warning", "message", "output", "notOutput", "ignore.warning")
371371
# Check if y was explicitly provided (not just the default)
372372
y_provided = !missing(y)
373-
compare = !y_provided && length(levels)>1L && !any(vapply_1b(vector_params, function(p) length(get(p, envir=environment())) > 0L))
373+
compare = !y_provided && length(optimization)>1L && !any(vapply_1b(vector_params, function(p) length(get(p, envir=environment())) > 0L))
374374

375-
for (i in seq_along(levels)) {
375+
for (i in seq_along(optimization)) {
376376
cl$num = num + (i - 1L) * 1e-6
377-
opt_level = list(datatable.optimize = levels[i])
377+
opt_level = list(datatable.optimize = optimization[i])
378378
cl$options = if (!is.null(options)) c(as.list(options), opt_level) else opt_level
379379
for (p in vector_params) {
380380
val = get(p, envir=environment())
381381
if (length(val) > 0L) {
382-
cl[[p]] = val[((i - 1L) %% length(val)) + 1L] # cycle through values if fewer than levels
382+
cl[[p]] = val[((i - 1L) %% length(val)) + 1L] # cycle through values if fewer than optimization levels
383383
}
384384
}
385385

inst/tests/benchmark.Rraw

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,10 +193,10 @@ test(301.1, nrow(DT[,sum(B),by=C])==100010)
193193
set.seed(1)
194194
DT = data.table(a=sample(1:100, 1e6, replace=TRUE), b=sample(1:1000, 1e6, replace=TRUE), key="a")
195195
opt = c(0L,2L)
196-
test(637.1, levels=opt, copy(DT)[, m:=sum(b), by=a][1:3], data.table(a=1L, b=c(156L, 808L, 848L), m=DT[J(1), sum(b)], key="a"))
197-
test(637.2, levels=opt, key(copy(DT)[J(43L), a:=99L]), NULL)
196+
optimization=opt, copy(DT)[, m:=sum(b), by=a][1:3], data.table(a=1L, b=c(156L, 808L, 848L), m=DT[J(1), sum(b)], key="a"))
197+
optimization=opt, key(copy(DT)[J(43L), a:=99L]), NULL)
198198
setkey(DT, a)
199-
test(637.3, levels=opt, key(copy(DT)[, a:=99L, by=a]), NULL)
199+
optimization=opt, key(copy(DT)[, a:=99L, by=a]), NULL)
200200

201201
# Test X[Y] slowdown, #2216
202202
# Many minutes in 1.8.2! Now well under 1s, but 10s for very wide tolerance for CRAN. We'd like CRAN to tell us if any changes

0 commit comments

Comments
 (0)