Skip to content

Commit 42aeddf

Browse files
Progress deprecation of logicalAsInt (#6646)
Co-authored-by: Benjamin Schwendinger <[email protected]>
1 parent 0578714 commit 42aeddf

File tree

4 files changed

+10
-16
lines changed

4 files changed

+10
-16
lines changed

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,8 @@ rowwiseDT(
143143
144144
9. `key<-`, marked as deprecated since 2012 and unusable since v1.15.0, has been fully removed.
145145
146+
10. 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.
147+
146148
# data.table [v1.16.2](https://github.com/Rdatatable/data.table/milestone/35) (9 October 2024)
147149
148150
## BUG FIXES

R/fwrite.R

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ fwrite = function(x, file="", append=FALSE, quote="auto",
33
sep2=c("","|",""), eol=if (.Platform$OS.type=="windows") "\r\n" else "\n",
44
na="", dec=".", row.names=FALSE, col.names=TRUE,
55
qmethod=c("double","escape"),
6-
logical01=getOption("datatable.logical01", FALSE),
7-
logicalAsInt=logical01,
6+
logical01=getOption("datatable.logical01", FALSE), # due to change to TRUE; see NEWS
7+
logicalAsInt=NULL,
88
scipen=getOption('scipen', 0L),
99
dateTimeAs = c("ISO","squash","epoch","write.csv"),
1010
buffMB=8, nThread=getDTthreads(verbose),
@@ -24,12 +24,8 @@ fwrite = function(x, file="", append=FALSE, quote="auto",
2424
else if (length(dateTimeAs)>1L) stopf("dateTimeAs must be a single string")
2525
dateTimeAs = chmatch(dateTimeAs, c("ISO","squash","epoch","write.csv"))-1L
2626
if (is.na(dateTimeAs)) stopf("dateTimeAs must be 'ISO','squash','epoch' or 'write.csv'")
27-
if (!missing(logical01) && !missing(logicalAsInt))
28-
stopf("logicalAsInt has been renamed logical01. Use logical01 only, not both.")
29-
if (!missing(logicalAsInt)) {
30-
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.")
31-
logical01 = logicalAsInt
32-
logicalAsInt=NULL
27+
if (!is.null(logicalAsInt)) {
28+
stopf("logicalAsInt has been renamed logical01 for consistency with fread.")
3329
}
3430
scipen = if (is.numeric(scipen)) as.integer(scipen) else 0L
3531
buffMB = as.integer(buffMB)

inst/tests/tests.Rraw

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10933,10 +10933,7 @@ test(1736.03, fwrite(DT, sep2=c("",",","")), error="sep.*,.*sep2.*,.*must all be
1093310933
test(1736.04, fwrite(DT, sep2=c("","||","")), error="nchar.*sep2.*2")
1093410934
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)",
1093510935
"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)"))
10936-
test(1736.06, capture.output(fwrite(DT, sep='|', sep2=c("{",",","}"), logicalAsInt=TRUE)),
10937-
c("A|B|C", "1|{1,2,3,4,5,6,7,8,9,10}|{s,t,u,v,w}",
10938-
"2|{15,16,17,18}|{1.2,2.3,3.4,3.14159265358979,-9}", "3|{7}|{foo,bar}", "4|{9,10}|{1,1,0}"),
10939-
warning="logicalAsInt has been renamed logical01")
10936+
test(1736.06, fwrite(DT, sep='|', sep2=c("{",",","}"), logicalAsInt=TRUE), error="logicalAsInt has been renamed logical01")
1094010937
DT = data.table(A=c("foo","ba|r","baz"))
1094110938
test(1736.07, capture.output(fwrite(DT,na="")), c("A","foo","ba|r","baz")) # no list column so no need to quote
1094210939
test(1736.08, capture.output(fwrite(DT)), c("A","foo","ba|r","baz"))
@@ -15957,8 +15954,7 @@ DT[ , z := 0L]
1595715954
test(2074.31, dcast(DT, V1 ~ z, fun.aggregate=eval(quote(length)), value.var='z'),
1595815955
data.table(V1=c('a', 'b'), `0`=2:1,key='V1'))
1595915956

15960-
# fwrite both logical args
15961-
test(2074.32, fwrite(DT, logical01=TRUE, logicalAsInt=TRUE), error="logicalAsInt has been renamed")
15957+
# 2074.32 tested that setting both logical01 and logicalAsInt errored; no longer relevant
1596215958

1596315959
# merge.data.table
1596415960
test(2074.33, merge(DT, DT, by.x = 1i, by.y=1i), error="A non-empty vector of column names is required")

man/fwrite.Rd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ fwrite(x, file = "", append = FALSE, quote = "auto",
1111
eol = if (.Platform$OS.type=="windows") "\r\n" else "\n",
1212
na = "", dec = ".", row.names = FALSE, col.names = TRUE,
1313
qmethod = c("double","escape"),
14-
logical01 = getOption("datatable.logical01", FALSE),
15-
logicalAsInt = logical01, # deprecated
14+
logical01 = getOption("datatable.logical01", FALSE), # due to change to TRUE; see NEWS
15+
logicalAsInt = NULL, # deprecated
1616
scipen = getOption('scipen', 0L),
1717
dateTimeAs = c("ISO","squash","epoch","write.csv"),
1818
buffMB = 8L, nThread = getDTthreads(verbose),

0 commit comments

Comments
 (0)