Skip to content

Commit

Permalink
Merge branch 'master' into refactor-helper-function-issue-6702
Browse files Browse the repository at this point in the history
  • Loading branch information
nipun-gupta-3108 authored Jan 22, 2025
2 parents 154aabd + 7445df7 commit db7b822
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pkgup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
cp -R ${{ env.R_LIBS_USER }} library
R CMD INSTALL --library="library" $(ls -1t data.table_*.tar.gz | head -n 1) --html
mkdir -p doc/html
cp /usr/share/R/doc/html/{left.jpg,up.jpg,Rlogo.svg,R.css,index.html} doc/html
cp $(R RHOME)/doc/html/{left.jpg,up.jpg,Rlogo.svg,R.css,index.html} doc/html
Rscript -e 'utils::make.packages.html("library", docdir="doc")'
sed -i "s|file://|../..|g" doc/html/packages.html
mkdir -p public
Expand Down
9 changes: 5 additions & 4 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,12 @@ rowwiseDT(
9. `key<-`, marked as deprecated since 2012 and unusable since v1.15.0, has been fully removed.
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.
10. The following in-progress deprecations have proceeded:
11. Deprecation of `fread(autostart=)` has been upgraded to an error. It has been warning since v1.11.0 (6 years ago). The argument will be removed in the next release.
12. Deprecation of `droplevels(in.place=TRUE)` (warning since v1.16.0) has been upgraded from warning to error. The argument will be removed in the next release.
+ Using `fwrite(logicalAsInt=)` has been upgraded from a warning (since v1.15.0) to an error. It will be removed in the next release.
+ Using `fread(autostart=)` has been upgraded to an error. It has been warning since v1.11.0 (6 years ago). The argument will be removed in the next release.
+ Using `droplevels(in.place=TRUE)` (warning since v1.16.0) has been upgraded from warning to error. The argument will be removed in the next release.
+ Use of `:=` and `with=FALSE` in `[` has been upgraded from warning (since v1.15.0) to error. Long ago (before 2014), this was needed when, e.g., assigning to a vector of column names defined outside the table, but `with=FALSE` is no longer needed to do so: `DT[, (cols) := ...]` works fine.
# data.table [v1.16.4](https://github.com/Rdatatable/data.table/milestone/36) 4 December 2024
Expand Down
1 change: 1 addition & 0 deletions R/as.data.table.R
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ as.data.table.list = function(x,
}

as.data.table.data.frame = function(x, keep.rownames=FALSE, key=NULL, ...) {
if (is.data.table(x)) return(as.data.table.data.table(x)) # S3 is weird, #6739. Also # nocov; this is tested in 2302.{2,3}, not sure why it doesn't show up in coverage.
if (!identical(class(x), "data.frame")) return(as.data.table(as.data.frame(x)))
if (!isFALSE(keep.rownames)) {
# can specify col name to keep.rownames, #575; if it's the same as key,
Expand Down
16 changes: 4 additions & 12 deletions R/data.table.R
Original file line number Diff line number Diff line change
Expand Up @@ -705,19 +705,11 @@ replace_dot_alias = function(e) {
# j was substituted before dealing with i so that := can set allow.cartesian=FALSE (#800) (used above in i logic)
if (is.null(jsub)) return(NULL)

if (!with && jsub %iscall% ":=") {
# TODO: make these both errors (or single long error in both cases) in next release.
# i.e. using with=FALSE together with := at all will become an error. Eventually with will be removed.
if (is.null(names(jsub)) && is.name(jsub[[2L]])) {
warningf("with=FALSE together with := was deprecated in v1.9.4 released Oct 2014. Please wrap the LHS of := with parentheses; e.g., DT[,(myVar):=sum(b),by=a] to assign to column name(s) held in variable myVar. See ?':=' for other examples. As warned in 2014, this is now a warning.")
jsub[[2L]] = eval(jsub[[2L]], parent.frame(), parent.frame())
} else {
warningf("with=FALSE ignored, it isn't needed when using :=. See ?':=' for examples.")
}
with = TRUE
}

if (!with) {
if (jsub %iscall% ":=") {
# TODO(>=1.18.0): Simplify this error
stopf("with=FALSE together with := was deprecated in v1.9.4 released Oct 2014; this has been warning since v1.15.0. Please wrap the LHS of := with parentheses; e.g., DT[,(myVar):=sum(b),by=a] to assign to column name(s) held in variable myVar. See ?':=' for other examples.")
}
# missingby was already checked above before dealing with i
if (jsub %iscall% c("!", "-") && length(jsub)==2L) { # length 2 to only match unary, #2109
notj = TRUE
Expand Down
14 changes: 9 additions & 5 deletions inst/tests/tests.Rraw
Original file line number Diff line number Diff line change
Expand Up @@ -4655,7 +4655,7 @@ test(1241, DT[order(x,-y)], # optimized to forder()

DT = data.table(a=1:3, b=4:6)
myCol = "a"
test(1242.1, DT[2,myCol:=6L,with=FALSE], data.table(a=INT(1,6,3), b=4:6), warning="with=FALSE together with := was deprecated in v1.9.4 released Oct 2014. Please")
test(1242.1, DT[2,myCol:=6L,with=FALSE], error="with=FALSE together with := was deprecated in v1.9.4")
test(1242.2, DT[2,(myCol):=7L], data.table(a=INT(1,7,3), b=4:6))

# consistency of output type of mult, #340
Expand Down Expand Up @@ -13953,8 +13953,8 @@ test(1967.42, x[3, rollends = rep(TRUE, 10L)], error = 'rollends must be length
test(1967.43, x[ , ..], error = 'symbol .. is invalid')
test(1967.44, x[NULL], data.table(NULL))
test(1967.45, x[ , NULL], NULL)
test(1967.46, x[ , 'b' := 6:10, with = FALSE],
data.table(a = 1:5, b = 6:10), warning = 'with=FALSE ignored')
test(1967.46, x[ , 'b' := 6:10, with=FALSE], error='with=FALSE together with :=')
x[, b := 6:10]
test(1967.47, x[ , -1L, with = FALSE], data.table(b = 6:10))
test(1967.48, x[ , b, .SDcols = 'a'], 6:10,
warning = "This j doesn't use .SD")
Expand Down Expand Up @@ -20748,15 +20748,19 @@ test(2301.3, DT[order(a, -b, decreasing=c(TRUE, TRUE))], error="Mixing '-' with
test(2301.4, DT[order(a, b, decreasing=c(TRUE, TRUE, FALSE))], error="decreasing= has length 3")

# as.data.table should remove extra attributes from extended data.frames #5699
x = data.frame(a=c(1,5,3), b=c(2,4,6))
x = data.frame(a=c(1, 5, 3), b=c(2, 4, 6))
class(x) = c("tbl", "data.frame")
attr(x, "t1") = "a"
as.data.frame.tbl = function(x) {
attr(x, "t1") = NULL
class(x) = "data.frame"
x
}
test(2302, attr(as.data.table(y), "t1"), attr(as.data.frame(y), "t1"))
test(2302.1, attr(as.data.table(y), "t1"), attr(as.data.frame(y), "t1"))
class(x) = c("data.frame", "data.table", "data.frame") # #6739
test(2302.2, attr(as.data.table(y), "t1"), attr(as.data.frame(y), "t1"))
class(x) = c("data.frame", "data.table") # duplicate class is overkill
test(2302.3, attr(as.data.table(y), "t1"), attr(as.data.frame(y), "t1"))

# by=foo(KEY) does not retain key (no way to guarantee monotonic transformation), #5583
DT = data.table(a=1:2, key='a')
Expand Down

0 comments on commit db7b822

Please sign in to comment.