-
Notifications
You must be signed in to change notification settings - Fork 998
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Various fixes for R 3.3.0 #6383
Merged
Merged
Changes from 11 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
7de7e78
Add a new devcontainer for ancient R
MichaelChirico c5f7769
ws
MichaelChirico 5fbdb04
ws
MichaelChirico 076a5e3
Can't use |>
MichaelChirico fe17c66
Use ';' (not real newlines in docker string)
MichaelChirico 6ba971e
Add repos=; skip unavailable packages
MichaelChirico d7f2715
Missing ')'
MichaelChirico 4b968a4
Various fixes for R 3.3.0
MichaelChirico 94e0226
Workaround R CMD check apparent false positive
MichaelChirico b471ead
Merge branch 'master' into r-3-3-0
MichaelChirico f4edf82
nolint for workaround usage
MichaelChirico 4a08ee9
Accurate R version for removing safe_rep_len()
MichaelChirico ec035cc
even more precise comment about .Internal issue
MichaelChirico 84c7e29
merge comments
MichaelChirico File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,15 @@ nan_is_na = function(x) { | |
stopf("Argument 'nan' must be NA or NaN") | ||
} | ||
|
||
# In R 3.3.0, rep_len() strips attributes --> breaks data.table()'s internal recycle() helper. | ||
if (inherits(rep_len(Sys.Date(), 1L), "Date")) { | ||
# NB: safe_rep_len=rep_len throws an R CMD check error because it _appears_ to the AST | ||
# walker that we've used .Internal ourselves (which is not true, but codetools can't tell). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nice explanation |
||
safe_rep_len = function(x, n) rep_len(x, n) | ||
} else { | ||
safe_rep_len = function(x, n) rep(x, length.out = n) # nolint: rep_len_linter. | ||
} | ||
|
||
# endsWith no longer used from #5097 so no need to backport; prevent usage to avoid dev delay until GLCI's R 3.1.0 test | ||
endsWith = function(...) stop("Internal error: use endsWithAny instead of base::endsWith", call.=FALSE) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14787,49 +14787,54 @@ test(2029.2, fread(txt, quote=""), data.table(A=1:2, B=4:5, C=7:8), warning="Dis | |
test(2029.3, fread(txt, quote="", fill=TRUE), data.table(A=1:3, B=4:6, C=c(7:8,NA))) | ||
|
||
# .Last.updated #1885 | ||
# NB: assign .Last.updated outside test(), which itself might run :=/set() --> update the value again. | ||
# Seen on R 3.3.0, unsure why only there. | ||
d = data.table(a=1:4, b=2:5) | ||
d[, z:=5L] | ||
test(2030.01, .Last.updated, 4L) # new column | ||
d[, z:=6L] | ||
test(2030.02, .Last.updated, 4L) # update existing column | ||
d[2:3, z:=7L] | ||
test(2030.03, .Last.updated, 2L) # sub assign | ||
d[integer(), z:=8L] | ||
test(2030.04, .Last.updated, 0L) # empty sub-assign | ||
d[-1L, z:=9L] | ||
test(2030.05, .Last.updated, 3L) # inverse sub-assign | ||
d[-(1:4), z:=10L] | ||
test(2030.06, .Last.updated, 0L) # inverse empty sub-assign | ||
# On R 3.3.0, .Last.updated gets touched by test() itself and this cascades even to re-assignments | ||
# of .Last.updated like n_updated=.Last.updated, so really force a deep copy by round-tripping from string. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. again thanks for the clear explanation |
||
force_copy = function(n) as.integer(sprintf("%d", n)) | ||
d[, z:=5L]; n_updated = force_copy(.Last.updated) | ||
test(2030.01, n_updated, 4L) # new column | ||
d[, z:=6L]; n_updated = force_copy(.Last.updated) | ||
test(2030.02, n_updated, 4L) # update existing column | ||
d[2:3, z:=7L]; n_updated = force_copy(.Last.updated) | ||
test(2030.03, n_updated, 2L) # sub assign | ||
d[integer(), z:=8L]; n_updated = force_copy(.Last.updated) | ||
test(2030.04, n_updated, 0L) # empty sub-assign | ||
d[-1L, z:=9L]; n_updated = force_copy(.Last.updated) | ||
test(2030.05, n_updated, 3L) # inverse sub-assign | ||
d[-(1:4), z:=10L]; n_updated = force_copy(.Last.updated) | ||
test(2030.06, n_updated, 0L) # inverse empty sub-assign | ||
d[, z:=NULL]; n_updated = force_copy(.Last.updated) | ||
test(2030.07, n_updated, 4L) # delete column | ||
d[2:3, z:=11L]; n_updated = force_copy(.Last.updated) | ||
test(2030.08, n_updated, 2L) # new column during sub-assign | ||
d[, z:=NULL] | ||
test(2030.07, .Last.updated, 4L) # delete column | ||
d[2:3, z:=11L] | ||
test(2030.08, .Last.updated, 2L) # new column during sub-assign | ||
d[integer(), z:=12L]; n_updated = force_copy(.Last.updated) | ||
test(2030.09, n_updated, 0L) # new columns from empty sub-assign | ||
d[, z:=NULL] | ||
d[integer(), z:=12L] | ||
test(2030.09, .Last.updated, 0L) # new columns from empty sub-assign | ||
d[, z:=NULL] | ||
d[-(1:4), z:=13L] | ||
test(2030.10, .Last.updated, 0L) # new columns from empty inverse sub-assign | ||
d[, z:=NULL][, z:=14L] | ||
test(2030.11, .Last.updated, 4L) # new column from chaining | ||
d[, z:=NULL][2:3, z:=14L] | ||
test(2030.12, .Last.updated, 2L) # sub-assign from chaining | ||
d[2:3, z:=14L][, z:=NULL] | ||
test(2030.13, .Last.updated, 4L) # delete column from chaining | ||
set(d, 1:2, "z", 15L) | ||
test(2030.14, .Last.updated, 2L) # set() updates .Last.updated too | ||
d[-(1:4), z:=13L]; n_updated = force_copy(.Last.updated) | ||
test(2030.10, n_updated, 0L) # new columns from empty inverse sub-assign | ||
d[, z:=NULL][, z:=14L]; n_updated = force_copy(.Last.updated) | ||
test(2030.11, n_updated, 4L) # new column from chaining | ||
d[, z:=NULL][2:3, z:=14L]; n_updated = force_copy(.Last.updated) | ||
test(2030.12, n_updated, 2L) # sub-assign from chaining | ||
d[2:3, z:=14L][, z:=NULL]; n_updated = force_copy(.Last.updated) | ||
test(2030.13, n_updated, 4L) # delete column from chaining | ||
set(d, 1:2, "z", 15L); n_updated = force_copy(.Last.updated) | ||
test(2030.14, n_updated, 2L) # set() updates .Last.updated too | ||
g = data.table(a=1:4, z=15L) # join | ||
d[g, on="a", z:=i.z] | ||
test(2030.15, .Last.updated, 4L) # all match of all rows | ||
d[g, on="a", z:=i.z]; n_updated = force_copy(.Last.updated) | ||
test(2030.15, n_updated, 4L) # all match of all rows | ||
g = data.table(a=2:4, z=16L) # join | ||
d[, z:=NULL][g, on="a", z:=i.z] | ||
test(2030.16, .Last.updated, 3L) # all match | ||
d[, z:=NULL][g, on="a", z:=i.z]; n_updated = force_copy(.Last.updated) | ||
test(2030.16, n_updated, 3L) # all match | ||
g = data.table(a=c(2L,4L,6L), z=17L) | ||
d[, z:=NULL][g, on="a", z:=i.z] | ||
test(2030.17, .Last.updated, 2L) # partial match | ||
d[, z:=NULL][g, on="a", z:=i.z]; n_updated = force_copy(.Last.updated) | ||
test(2030.17, n_updated, 2L) # partial match | ||
g = data.table(a=5:6, z=18L) | ||
d[, z:=NULL][g, on="a", z:=i.z] | ||
test(2030.18, .Last.updated, 0L) # zero match | ||
d[, z:=NULL][g, on="a", z:=i.z]; n_updated = force_copy(.Last.updated) | ||
test(2030.18, n_updated, 0L) # zero match | ||
|
||
# rbind vec with list regression dev 1.12.3; #3528 | ||
test(2031.01, rbind(data.table(A=1:3, B=7:9), data.table(A=4:6, B=as.list(10:12))), ans<-data.table(A=1:6, B=as.list(7:12))) | ||
|
@@ -18453,7 +18458,7 @@ rm(.datatable.aware) | |
local({ | ||
lc_ctype = Sys.getlocale('LC_CTYPE') | ||
Sys.setlocale('LC_CTYPE', "en_US.UTF-8") # Japanese multibyte characters require utf8 | ||
on.exit({Sys.setlocale('LC_CTYPE', lc_ctype)}) | ||
on.exit(Sys.setlocale('LC_CTYPE', lc_ctype)) | ||
accented_a = "\u0061\u0301" | ||
ja_ichi = "\u4E00" | ||
ja_ni = "\u4E8C" | ||
|
@@ -18718,7 +18723,7 @@ test(2264.8, print(DT, show.indices=TRUE), output=ans) | |
# integer64 columns print even when bit64 isn't loaded | ||
if (test_bit64) local({ | ||
DT = data.table(a = 'abc', b = as.integer64(1)) | ||
invisible(unloadNamespace("bit64")) | ||
suppressPackageStartupMessages(unloadNamespace("bit64")) | ||
on.exit(suppressPackageStartupMessages(library(bit64))) | ||
test(2265, DT, output="abc\\s*1$") | ||
}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just checked and this seems still a problem at
3.6.0
so we might need to hold on to this for quite some time, but it would be best to check at which version this is fixed inR
and add a commentThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for checking. I suspected that might be the case -- I checked the R NEWS and NEWS.3 files and didn't see anything relevant here (searching 'attrib', 'rep_len'), and glanced at the
rep_len()
blame to see if anything about attributes popped out, no luck.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually looking again, I think it's this:
r-devel/r-svn@70e8a3f
Then
rep_len()
onDate
dispatches torep.Date()
.That puts us in R 4.0.0:
https://github.com/r-devel/r-svn/blob/874fa1008e6cb090c7c898c422d703ca0026d600/doc/NEWS.Rd#L4885-L4887