Skip to content

Commit

Permalink
Don't warn about numeric coercion in set(j=)
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelChirico authored Oct 31, 2024
1 parent afa87e1 commit f6c1385
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ rowwiseDT(
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).
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.

# data.table [v1.16.0](https://github.com/Rdatatable/data.table/milestone/30) (25 August 2024)

## BREAKING CHANGES
Expand Down
3 changes: 2 additions & 1 deletion src/assign.c
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,8 @@ SEXP assign(SEXP dt, SEXP rows, SEXP cols, SEXP newcolnames, SEXP values)
} else {
if (isReal(cols)) {
cols = PROTECT(coerceVector(cols, INTSXP)); protecti++;
warning(_("Coerced j from numeric to integer. Please pass integer for efficiency; e.g., 2L rather than 2"));
if (verbose)
Rprintf(_("Coerced j from numeric to integer. Please pass integer for efficiency; e.g., 2L rather than 2"));
}
if (!isInteger(cols))
error(_("j is type '%s'. Must be integer, character, or numeric is coerced with warning."), type2char(TYPEOF(cols)));
Expand Down

0 comments on commit f6c1385

Please sign in to comment.