Skip to content

Commit 057adb3

Browse files
Merge branch 'master' into depr-logasint
2 parents dae865a + fc43386 commit 057adb3

File tree

13 files changed

+97
-70
lines changed

13 files changed

+97
-70
lines changed

.ci/.lintr.R

Lines changed: 34 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -71,45 +71,39 @@ linters = c(dt_linters, all_linters(
7171
))
7272
rm(dt_linters)
7373

74-
# TODO(lintr#2172): Glob with lintr itself.
75-
exclusions = c(local({
76-
exclusion_for_dir <- function(dir, exclusions) {
77-
files = file.path("..", list.files(dir, pattern = "\\.(R|Rmd|Rraw)$", full.names=TRUE))
78-
stats::setNames(rep(list(exclusions), length(files)), files)
79-
}
80-
c(
81-
exclusion_for_dir("tests", list(
82-
quotes_linter = Inf,
83-
# TODO(michaelchirico): Enforce these and re-activate them one-by-one.
84-
implicit_integer_linter = Inf,
85-
infix_spaces_linter = Inf,
86-
undesirable_function_linter = Inf
87-
)),
88-
exclusion_for_dir(c("vignettes", "vignettes/fr", "vignettes/ru"), list(
89-
# assignment_linter = Inf,
90-
implicit_integer_linter = Inf,
91-
quotes_linter = Inf,
92-
sample_int_linter = Inf
93-
# strings_as_factors_linter = Inf
94-
# system_time_linter = Inf
95-
)),
96-
exclusion_for_dir("inst/tests", list(
97-
library_call_linter = Inf,
98-
numeric_leading_zero_linter = Inf,
99-
undesirable_operator_linter = Inf, # For ':::', possibly we could be more careful to only exclude ':::'.
100-
# TODO(michaelchirico): Enforce these and re-activate them one-by-one.
101-
comparison_negation_linter = Inf,
102-
condition_call_linter = Inf,
103-
duplicate_argument_linter = Inf,
104-
equals_na_linter = Inf,
105-
missing_argument_linter = Inf,
106-
paste_linter = Inf,
107-
rep_len_linter = Inf,
108-
sample_int_linter = Inf,
109-
seq_linter = Inf,
110-
unnecessary_lambda_linter = Inf
111-
))
74+
exclusions = list(
75+
`../tests` = list(
76+
quotes_linter = Inf,
77+
# TODO(michaelchirico): Enforce these and re-activate them one-by-one.
78+
implicit_integer_linter = Inf,
79+
infix_spaces_linter = Inf,
80+
undesirable_function_linter = Inf
81+
),
82+
`../vignettes*` = list(
83+
# assignment_linter = Inf,
84+
implicit_integer_linter = Inf,
85+
quotes_linter = Inf,
86+
sample_int_linter = Inf
87+
# strings_as_factors_linter = Inf
88+
# system_time_linter = Inf
89+
),
90+
`../inst/tests` = list(
91+
library_call_linter = Inf,
92+
numeric_leading_zero_linter = Inf,
93+
undesirable_operator_linter = Inf, # For ':::', possibly we could be more careful to only exclude ':::'.
94+
# TODO(michaelchirico): Enforce these and re-activate them one-by-one.
95+
comparison_negation_linter = Inf,
96+
condition_call_linter = Inf,
97+
duplicate_argument_linter = Inf,
98+
equals_na_linter = Inf,
99+
missing_argument_linter = Inf,
100+
paste_linter = Inf,
101+
rep_len_linter = Inf,
102+
sample_int_linter = Inf,
103+
seq_linter = Inf,
104+
unnecessary_lambda_linter = Inf
105+
),
106+
`../inst/tests/froll.Rraw` = list(
107+
dt_test_literal_linter = Inf # TODO(michaelchirico): Fix these once #5898, #5692, #5682, #5576, #5575, #5441 are merged.
112108
)
113-
}),
114-
list(`../inst/tests/froll.Rraw` = list(dt_test_literal_linter = Inf)) # TODO(michaelchirico): Fix these once #5898, #5692, #5682, #5576, #5575, #5441 are merged.
115109
)

DESCRIPTION

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ Authors@R: c(
1515
person("Tyson","Barrett", role=c("aut","cre"), email="[email protected]", comment = c(ORCID="0000-0002-2137-1391")),
1616
person("Matt","Dowle", role="aut", email="[email protected]"),
1717
person("Arun","Srinivasan", role="aut", email="[email protected]"),
18-
person("Jan","Gorecki", role="aut"),
19-
person("Michael","Chirico", role="aut", comment = c(ORCID="0000-0003-0787-087X")),
20-
person("Toby","Hocking", role="aut", comment = c(ORCID="0000-0002-3146-0865")),
18+
person("Jan","Gorecki", role="aut", email="[email protected]"),
19+
person("Michael","Chirico", role="aut", email="[email protected]", comment = c(ORCID="0000-0003-0787-087X")),
20+
person("Toby","Hocking", role="aut", email="[email protected]", comment = c(ORCID="0000-0002-3146-0865")),
2121
person("Benjamin","Schwendinger",role="aut", comment = c(ORCID="0000-0003-3315-8114")),
2222
person("Ivan", "Krylov", role="aut", email="[email protected]", comment = c(ORCID="0000-0002-0172-3812")),
2323
person("Pasha","Stetsenko", role="ctb"),

NEWS.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,13 @@
1010

1111
1. Custom binary operators from the `lubridate` package now work with objects of class `IDate` as with a `Date` subclass, [#6839](https://github.com/Rdatatable/data.table/issues/6839). Thanks @emallickhossain for the report and @aitap for the fix.
1212

13+
2. `fwrite(compress="gzip")` once again produces a gzip header when the column names are missing or disabled, [@6852](https://github.com/Rdatatable/data.table/issues/6852). Thanks @maxscheiber for the report and @aitap for the fix.
14+
1315
## NOTES
1416

15-
1. The following in-progress deprecations have proceeded:
17+
1. Continued work to remove non-API C functions, [#6180](https://github.com/Rdatatable/data.table/issues/6180). Thanks Ivan Krylov for the PRs and for writing a clear and concise guide about the R API: https://aitap.codeberg.page/R-api/.
18+
19+
2. The following in-progress deprecations have proceeded:
1620

1721
+ Argument `logicalAsInt` to `fwrite()` has been removed.
1822

R/IDateTime.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ as.IDate.POSIXct = function(x, tz = attr(x, "tzone", exact=TRUE), ...) {
4040
if (is_utc(tz))
4141
(setattr(as.integer(as.numeric(x) %/% 86400L), "class", c("IDate", "Date"))) # %/% returns new object so can use setattr() on it; wrap with () to return visibly
4242
else
43-
as.IDate(as.Date(x, tz = if (is.null(tz)) '' else tz, ...))
43+
as.IDate(as.Date(x, tz = tz %||% '', ...))
4444
}
4545

4646
as.IDate.IDate = function(x, ...) x
@@ -147,7 +147,7 @@ as.ITime.default = function(x, ...) {
147147

148148
as.ITime.POSIXct = function(x, tz = attr(x, "tzone", exact=TRUE), ...) {
149149
if (is_utc(tz)) as.ITime(unclass(x), ...)
150-
else as.ITime(as.POSIXlt(x, tz = if (is.null(tz)) '' else tz, ...), ...)
150+
else as.ITime(as.POSIXlt(x, tz = tz %||% '', ...), ...)
151151
}
152152

153153
as.ITime.numeric = function(x, ms = 'truncate', ...) {

R/between.R

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ between = function(x, lower, upper, incbounds=TRUE, NAbounds=TRUE, check=FALSE)
1818
# POSIX check timezone match
1919
if (is.px(x) && is.px(lower) && is.px(upper)) {
2020
tzs = sapply(list(x,lower,upper), function(x) {
21-
tt = attr(x,"tzone",exact=TRUE)
22-
if (is.null(tt)) "" else tt
21+
attr(x, "tzone", exact=TRUE) %||% ""
2322
})
2423
# lower/upper should be more tightly linked than x/lower, so error
2524
# if the former don't match but only inform if they latter don't

R/data.table.R

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,7 @@ replace_dot_alias = function(e) {
640640
# Doing this once here, helps speed later when repeatedly subsetting each column. R's [irows] would do this for each
641641
# column when irows contains negatives.
642642
}
643-
if (which) return( if (is.null(irows)) seq_len(nrow(x)) else irows )
643+
if (which) return(irows %||% seq_len(nrow(x)))
644644
} else { # missing(i)
645645
i = NULL
646646
}
@@ -757,7 +757,7 @@ replace_dot_alias = function(e) {
757757
if (".I" %in% bysubl) { #1732
758758
if (!is.symbol(bysub) && (length(bysubl)!=2L || !is.symbol(bysubl[[2L]]) || !(bysubl[[1L]] %chin% c(".","c","list"))))
759759
stopf("'by' contains .I but only the following are currently supported: by=.I, by=.(.I), by=c(.I), by=list(.I)")
760-
bysub = if (is.null(irows)) seq_len(nrow(x)) else irows
760+
bysub = irows %||% seq_len(nrow(x))
761761
bysuborig = as.symbol("I")
762762
}
763763
if (is.name(bysub) && !(bysub %chin% names_x)) { # TO DO: names(x),names(i),and i. and x. prefixes
@@ -1724,7 +1724,7 @@ replace_dot_alias = function(e) {
17241724
jl__ = as.list(jsubl[[i_]])[-1L] # just keep the '.' from list(.)
17251725
if (isTRUE(nzchar(names(jsubl)[i_]))) {
17261726
# Fix for #2311, prepend named list arguments of c() to that list's names. See tests 2283.*
1727-
njl__ = if (is.null(names(jl__))) rep("", length(jl__)) else names(jl__)
1727+
njl__ = names(jl__) %||% rep("", length(jl__))
17281728
njl__nonblank = nzchar(names(jl__))
17291729
if (length(jl__) > 1L) {
17301730
jn__ = paste0(names(jsubl)[i_], seq_along(jl__))
@@ -1733,7 +1733,7 @@ replace_dot_alias = function(e) {
17331733
}
17341734
jn__[njl__nonblank] = paste(names(jsubl)[i_], njl__[njl__nonblank], sep=".")
17351735
} else {
1736-
jn__ = if (is.null(names(jl__))) rep("", length(jl__)) else names(jl__)
1736+
jn__ = names(jl__) %||% rep("", length(jl__))
17371737
}
17381738
idx = unlist(lapply(jl__, function(x) is.name(x) && x == ".I"))
17391739
if (any(idx))
@@ -2164,7 +2164,7 @@ as.matrix.data.table = function(x, rownames=NULL, rownames.value=NULL, ...) {
21642164
# retain highest type of input for empty output, #4762
21652165
if (length(X)!=0L)
21662166
internal_error("length(X)==%d but a dimension is zero", length(X)) # nocov
2167-
return(array(if (is.null(X)) NA else X, dim = dm, dimnames = list(rownames.value, cn)))
2167+
return(array(X %||% NA, dim=dm, dimnames=list(rownames.value, cn)))
21682168
}
21692169
dim(X) = c(n, length(X)/n)
21702170
dimnames(X) = list(rownames.value, unlist(collabs, use.names = FALSE))

R/foverlaps.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
foverlaps = function(x, y, by.x=if (!is.null(key(x))) key(x) else key(y), by.y=key(y), maxgap=0L, minoverlap=1L, type=c("any", "within", "start", "end", "equal"), mult=c("all", "first", "last"), nomatch=NA, which=FALSE, verbose=getOption("datatable.verbose")) {
1+
foverlaps = function(x, y, by.x=key(x) %||% key(y), by.y=key(y), maxgap=0L, minoverlap=1L, type=c("any", "within", "start", "end", "equal"), mult=c("all", "first", "last"), nomatch=NA, which=FALSE, verbose=getOption("datatable.verbose")) {
22

33
if (!is.data.table(y) || !is.data.table(x)) stopf("y and x must both be data.tables. Use `setDT()` to convert list/data.frames to data.tables by reference or as.data.table() to convert to data.tables by copying.")
44
maxgap = as.integer(maxgap); minoverlap = as.integer(minoverlap)
@@ -78,7 +78,7 @@ foverlaps = function(x, y, by.x=if (!is.null(key(x))) key(x) else key(y), by.y=k
7878
stopf("Some interval cols are of type POSIXct while others are not. Please ensure all interval cols are (or are not) of POSIXct type")
7979
}
8080
# #1143, mismatched timezone
81-
getTZ = function(x) if (is.null(tz <- attr(x, "tzone", exact=TRUE))) "" else tz # "" == NULL AFAICT
81+
getTZ = function(x) attr(x, "tzone", exact=TRUE) %||% "" # "" == NULL AFAICT
8282
tzone_chk = c(getTZ(xval1), getTZ(xval2), getTZ(yval1), getTZ(yval2))
8383
if (length(unique(tzone_chk)) > 1L) {
8484
warningf("POSIXct interval cols have mixed timezones. Overlaps are performed on the internal numerical representation of POSIXct objects (always in UTC epoch time), therefore printed values may give the impression that values don't overlap but their internal representations do Please ensure that POSIXct type interval cols have identical 'tzone' attributes to avoid confusion.")

R/print.data.table.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ paste_dims = function(x) {
172172
dims = if (isS4(x)) {
173173
length(slotNames(x))
174174
} else {
175-
if (is.null(dim(x))) length(x) else dim(x)
175+
dim(x) %||% length(x)
176176
}
177177
paste0("[", paste(dims,collapse="x"), "]")
178178
}

R/utils.R

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ nan_is_na = function(x) {
2121
stopf("Argument 'nan' must be NA or NaN")
2222
}
2323

24+
# R 4.4.0
25+
if (!exists("%||%", "package:base")) `%||%` <- function(x, y) if (is.null(x)) y else x # nolint: coalesce_linter.
26+
2427
internal_error = function(...) {
2528
e1 = gettext("Internal error in")
2629
e2 = deparse(head(tail(sys.calls(), 2L), 1L)[[1L]][[1L]])

inst/tests/tests.Rraw

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10024,10 +10024,13 @@ if (!haszlib()) {
1002410024
fwrite(DT, file=f3<-tempfile(), compress="gzip") # compress to filename not ending .gz
1002510025
fwrite(DT, file=f4<-tempfile(), compress="gzip", compressLevel=1) # test compressLevel
1002610026
fwrite(DT, file=f5<-tempfile(), compress="gzip", compressLevel=9)
10027+
# col.names=FALSE must not disable gzip header, #6852
10028+
fwrite(DT, file=f6<-tempfile(), compress="gzip", col.names=FALSE)
1002710029
test(1658.441, file.info(f3)$size, file.info(f1)$size)
1002810030
test(1658.442, file.info(f4)$size >= file.info(f1)$size)
1002910031
test(1658.443, file.info(f1)$size >= file.info(f5)$size)
10030-
unlink(c(f1,f2,f3,f4,f5))
10032+
test(1658.444, fread(f6, col.names = c("a", "b")), DT)
10033+
unlink(c(f1,f2,f3,f4,f5,f6))
1003110034
}
1003210035
DT = data.table(a=1:3, b=list(1:4, c(3.14, 100e10), c("foo", "bar", "baz")))
1003310036
test(1658.45, fwrite(DT), output=c("a,b","1,1|2|3|4","2,3.14|1e+12","3,foo|bar|baz"))

0 commit comments

Comments
 (0)