Skip to content

Commit c64948f

Browse files
Progress deprecation of logicalAsInt
1 parent 436bd6c commit c64948f

File tree

4 files changed

+8
-14
lines changed

4 files changed

+8
-14
lines changed

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ rowwiseDT(
137137

138138
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).
139139

140+
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.
141+
140142
# data.table [v1.16.2](https://github.com/Rdatatable/data.table/milestone/35) (9 October 2024)
141143

142144
## BUG FIXES

R/fwrite.R

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ fwrite = function(x, file="", append=FALSE, quote="auto",
44
na="", dec=".", row.names=FALSE, col.names=TRUE,
55
qmethod=c("double","escape"),
66
logical01=getOption("datatable.logical01", FALSE), # due to change to TRUE; see NEWS
7-
logicalAsInt=logical01,
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
@@ -10937,10 +10937,7 @@ test(1736.03, fwrite(DT, sep2=c("",",","")), error="sep.*,.*sep2.*,.*must all be
1093710937
test(1736.04, fwrite(DT, sep2=c("","||","")), error="nchar.*sep2.*2")
1093810938
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)",
1093910939
"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)"))
10940-
test(1736.06, capture.output(fwrite(DT, sep='|', sep2=c("{",",","}"), logicalAsInt=TRUE)),
10941-
c("A|B|C", "1|{1,2,3,4,5,6,7,8,9,10}|{s,t,u,v,w}",
10942-
"2|{15,16,17,18}|{1.2,2.3,3.4,3.14159265358979,-9}", "3|{7}|{foo,bar}", "4|{9,10}|{1,1,0}"),
10943-
warning="logicalAsInt has been renamed logical01")
10940+
test(1736.06, fwrite(DT, sep='|', sep2=c("{",",","}"), logicalAsInt=TRUE), error="logicalAsInt has been renamed logical01")
1094410941
DT = data.table(A=c("foo","ba|r","baz"))
1094510942
test(1736.07, capture.output(fwrite(DT,na="")), c("A","foo","ba|r","baz")) # no list column so no need to quote
1094610943
test(1736.08, capture.output(fwrite(DT)), c("A","foo","ba|r","baz"))
@@ -15961,8 +15958,7 @@ DT[ , z := 0L]
1596115958
test(2074.31, dcast(DT, V1 ~ z, fun.aggregate=eval(quote(length)), value.var='z'),
1596215959
data.table(V1=c('a', 'b'), `0`=2:1,key='V1'))
1596315960

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

1596715963
# merge.data.table
1596815964
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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ fwrite(x, file = "", append = FALSE, quote = "auto",
1212
na = "", dec = ".", row.names = FALSE, col.names = TRUE,
1313
qmethod = c("double","escape"),
1414
logical01 = getOption("datatable.logical01", FALSE), # due to change to TRUE; see NEWS
15-
logicalAsInt = logical01, # deprecated
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)