From f6c138575f5157bebde0ff0c22601cd1ec983bd4 Mon Sep 17 00:00:00 2001 From: Michael Chirico Date: Thu, 31 Oct 2024 09:52:47 -0700 Subject: [PATCH] Don't warn about numeric coercion in set(j=) --- NEWS.md | 2 ++ src/assign.c | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index 4236e8b078..59f25a77f7 100644 --- a/NEWS.md +++ b/NEWS.md @@ -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 diff --git a/src/assign.c b/src/assign.c index b280c2259f..2f6715e83b 100644 --- a/src/assign.c +++ b/src/assign.c @@ -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)));