Skip to content

Commit 9319e15

Browse files
also demote condition for 'i'
1 parent 2926ad9 commit 9319e15

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

NEWS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
+ On non-Windows systems, `fread()` now prints the reason why the file couldn't be opened, which could also be due to it being too large to map.
9090
+ With `verbose=TRUE`, file sizes are now printed using correct binary SI prefixes (the sizes have always been reported as bytes denominated in powers of `2^10`, so e.g. `1024*1024` bytes was reported as `1 MB` where `1 MiB` or `1.05 MB` is correct).
9191
92-
5. Using a double vector in `set()`'s `j=` no longer throws a warning about preferring integer, [#6594](https://github.com/Rdatatable/data.table/issues/6594). While it may improve efficiency to use integer, there's no guarantee it's an improvement and the difference is likely to be minimal. The coercion will still be reported under `datatable.verbose=TRUE`. For package/production use cases, static analyzers such as `lintr::implicit_integer_linter()` can also report when numeric literals should be rewritten as integer literals.
92+
5. Using a double vector in `set()`'s `i=` and/or `j=` no longer throws a warning about preferring integer, [#6594](https://github.com/Rdatatable/data.table/issues/6594). While it may improve efficiency to use integer, there's no guarantee it's an improvement and the difference is likely to be minimal. The coercion will still be reported under `datatable.verbose=TRUE`. For package/production use cases, static analyzers such as `lintr::implicit_integer_linter()` can also report when numeric literals should be rewritten as integer literals.
9393

9494
## data.table [v1.17.0](https://github.com/Rdatatable/data.table/milestone/34) (20 Feb 2025)
9595

inst/tests/tests.Rraw

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1621,9 +1621,9 @@ test(514, x %chin% y, x %in% y)
16211621

16221622
# Test new function set() in v1.8.0
16231623
DT = data.table(a=1:3,b=4:6)
1624-
test(515, set(DT,2,1,3), data.table(a=c(1L,3L,3L),b=4:6), warning="Coerced i from numeric to integer")
1624+
test(515, set(DT,2,1,3), data.table(a=c(1L,3L,3L),b=4:6))
16251625
test(516, set(DT,"2",1,3), error="i is type 'character'")
1626-
test(517, options=c(datatable.verbose=TRUE), set(DT,2L,1,3), DT, output="Coerced j")
1626+
test(517, options=c(datatable.verbose=TRUE), set(DT,2,1,3), DT, output="Coerced i.*Coerced j")
16271627
# FR #2551 implemented - removed warning from 518
16281628
# test(518, set(DT,2L,1L,3), DT, warning="Coerced 'double' RHS to 'integer'")
16291629
test(518, set(DT,2L,1L,3), DT)

src/assign.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,8 @@ SEXP assign(SEXP dt, SEXP rows, SEXP cols, SEXP newcolnames, SEXP values)
365365
} else {
366366
if (isReal(rows)) {
367367
rows = PROTECT(coerceVector(rows, INTSXP)); protecti++;
368-
warning(_("Coerced i from numeric to integer. Please pass integer for efficiency; e.g., 2L rather than 2"));
368+
if (verbose)
369+
Rprintf(_("Coerced %s from numeric to integer. Passing integer directly may be more efficient, e.g., 2L rather than 2"), "i");
369370
}
370371
if (!isInteger(rows))
371372
error(_("i is type '%s'. Must be integer, or numeric is coerced with warning. If i is a logical subset, simply wrap with which(), and take the which() outside the loop if possible for efficiency."), type2char(TYPEOF(rows)));
@@ -419,7 +420,7 @@ SEXP assign(SEXP dt, SEXP rows, SEXP cols, SEXP newcolnames, SEXP values)
419420
if (isReal(cols)) {
420421
cols = PROTECT(coerceVector(cols, INTSXP)); protecti++;
421422
if (verbose)
422-
Rprintf(_("Coerced j from numeric to integer. Please pass integer for efficiency; e.g., 2L rather than 2"));
423+
Rprintf(_("Coerced %s from numeric to integer. Passing integer directly may be more efficient, e.g., 2L rather than 2"), "j");
423424
}
424425
if (!isInteger(cols))
425426
error(_("j is type '%s'. Must be integer, character, or numeric is coerced with warning."), type2char(TYPEOF(cols)));

0 commit comments

Comments
 (0)