Skip to content

Commit f6c1385

Browse files
Don't warn about numeric coercion in set(j=)
1 parent afa87e1 commit f6c1385

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ rowwiseDT(
133133
134134
8. `measurev()` was implemented and documented in v1.15.0, for use within `melt()`, and it is now exported (dependent packages can now use without a NOTE from CRAN check).
135135
136+
9. 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.
137+
136138
# data.table [v1.16.0](https://github.com/Rdatatable/data.table/milestone/30) (25 August 2024)
137139

138140
## BREAKING CHANGES

src/assign.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,8 @@ SEXP assign(SEXP dt, SEXP rows, SEXP cols, SEXP newcolnames, SEXP values)
425425
} else {
426426
if (isReal(cols)) {
427427
cols = PROTECT(coerceVector(cols, INTSXP)); protecti++;
428-
warning(_("Coerced j from numeric to integer. Please pass integer for efficiency; e.g., 2L rather than 2"));
428+
if (verbose)
429+
Rprintf(_("Coerced j from numeric to integer. Please pass integer for efficiency; e.g., 2L rather than 2"));
429430
}
430431
if (!isInteger(cols))
431432
error(_("j is type '%s'. Must be integer, character, or numeric is coerced with warning."), type2char(TYPEOF(cols)));

0 commit comments

Comments
 (0)