From c64948f2b16d7f1b6707f8fdd0a52a1c592c53cf Mon Sep 17 00:00:00 2001 From: Michael Chirico Date: Tue, 10 Dec 2024 09:33:29 +0800 Subject: [PATCH] Progress deprecation of logicalAsInt --- NEWS.md | 2 ++ R/fwrite.R | 10 +++------- inst/tests/tests.Rraw | 8 ++------ man/fwrite.Rd | 2 +- 4 files changed, 8 insertions(+), 14 deletions(-) diff --git a/NEWS.md b/NEWS.md index 885eb56c5b..5a47d169cc 100644 --- a/NEWS.md +++ b/NEWS.md @@ -137,6 +137,8 @@ rowwiseDT( 6. `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). +7. Deprecation of `logicalAsInt` argument to `fwrite()` has been upgraded from a warning (since v1.15.0) to an error. It will be removed in the next release. + # data.table [v1.16.2](https://github.com/Rdatatable/data.table/milestone/35) (9 October 2024) ## BUG FIXES diff --git a/R/fwrite.R b/R/fwrite.R index d67c886d13..210f1d0bf5 100644 --- a/R/fwrite.R +++ b/R/fwrite.R @@ -4,7 +4,7 @@ fwrite = function(x, file="", append=FALSE, quote="auto", na="", dec=".", row.names=FALSE, col.names=TRUE, qmethod=c("double","escape"), logical01=getOption("datatable.logical01", FALSE), # due to change to TRUE; see NEWS - logicalAsInt=logical01, + logicalAsInt=NULL, scipen=getOption('scipen', 0L), dateTimeAs = c("ISO","squash","epoch","write.csv"), buffMB=8, nThread=getDTthreads(verbose), @@ -24,12 +24,8 @@ fwrite = function(x, file="", append=FALSE, quote="auto", else if (length(dateTimeAs)>1L) stopf("dateTimeAs must be a single string") dateTimeAs = chmatch(dateTimeAs, c("ISO","squash","epoch","write.csv"))-1L if (is.na(dateTimeAs)) stopf("dateTimeAs must be 'ISO','squash','epoch' or 'write.csv'") - if (!missing(logical01) && !missing(logicalAsInt)) - stopf("logicalAsInt has been renamed logical01. Use logical01 only, not both.") - if (!missing(logicalAsInt)) { - warningf("logicalAsInt has been renamed logical01 for consistency with fread. It works fine for now but please change to logical01 at your convenience so we can remove logicalAsInt in future.") - logical01 = logicalAsInt - logicalAsInt=NULL + if (!is.null(logicalAsInt)) { + stopf("logicalAsInt has been renamed logical01 for consistency with fread.") } scipen = if (is.numeric(scipen)) as.integer(scipen) else 0L buffMB = as.integer(buffMB) diff --git a/inst/tests/tests.Rraw b/inst/tests/tests.Rraw index 657478c61f..17270d7eb1 100644 --- a/inst/tests/tests.Rraw +++ b/inst/tests/tests.Rraw @@ -10937,10 +10937,7 @@ test(1736.03, fwrite(DT, sep2=c("",",","")), error="sep.*,.*sep2.*,.*must all be test(1736.04, fwrite(DT, sep2=c("","||","")), error="nchar.*sep2.*2") test(1736.05, capture.output(fwrite(DT, sep='|', sep2=c("c(",",",")"), logical01=FALSE)), c("A|B|C", "1|c(1,2,3,4,5,6,7,8,9,10)|c(s,t,u,v,w)", "2|c(15,16,17,18)|c(1.2,2.3,3.4,3.14159265358979,-9)", "3|c(7)|c(foo,bar)", "4|c(9,10)|c(TRUE,TRUE,FALSE)")) -test(1736.06, capture.output(fwrite(DT, sep='|', sep2=c("{",",","}"), logicalAsInt=TRUE)), - c("A|B|C", "1|{1,2,3,4,5,6,7,8,9,10}|{s,t,u,v,w}", - "2|{15,16,17,18}|{1.2,2.3,3.4,3.14159265358979,-9}", "3|{7}|{foo,bar}", "4|{9,10}|{1,1,0}"), - warning="logicalAsInt has been renamed logical01") +test(1736.06, fwrite(DT, sep='|', sep2=c("{",",","}"), logicalAsInt=TRUE), error="logicalAsInt has been renamed logical01") DT = data.table(A=c("foo","ba|r","baz")) test(1736.07, capture.output(fwrite(DT,na="")), c("A","foo","ba|r","baz")) # no list column so no need to quote test(1736.08, capture.output(fwrite(DT)), c("A","foo","ba|r","baz")) @@ -15961,8 +15958,7 @@ DT[ , z := 0L] test(2074.31, dcast(DT, V1 ~ z, fun.aggregate=eval(quote(length)), value.var='z'), data.table(V1=c('a', 'b'), `0`=2:1,key='V1')) -# fwrite both logical args -test(2074.32, fwrite(DT, logical01=TRUE, logicalAsInt=TRUE), error="logicalAsInt has been renamed") +# 2074.32 tested that setting both logical01 and logicalAsInt errored; no longer relevant # merge.data.table test(2074.33, merge(DT, DT, by.x = 1i, by.y=1i), error="A non-empty vector of column names is required") diff --git a/man/fwrite.Rd b/man/fwrite.Rd index efa830fb9d..6cef5ec0ab 100644 --- a/man/fwrite.Rd +++ b/man/fwrite.Rd @@ -12,7 +12,7 @@ fwrite(x, file = "", append = FALSE, quote = "auto", na = "", dec = ".", row.names = FALSE, col.names = TRUE, qmethod = c("double","escape"), logical01 = getOption("datatable.logical01", FALSE), # due to change to TRUE; see NEWS - logicalAsInt = logical01, # deprecated + logicalAsInt = NULL, # deprecated scipen = getOption('scipen', 0L), dateTimeAs = c("ISO","squash","epoch","write.csv"), buffMB = 8L, nThread = getDTthreads(verbose),