Fixed typeorder coercion rules for RAWSXP and LGLSXP to match base R#4195
Closed
sritchie73 wants to merge 7 commits intomasterfrom
Closed
Fixed typeorder coercion rules for RAWSXP and LGLSXP to match base R#4195sritchie73 wants to merge 7 commits intomasterfrom
sritchie73 wants to merge 7 commits intomasterfrom
Conversation
Raw should be coerced to logical, not the other way round, e.g. c(TRUE, as.raw(1)) == c(TRUE, TRUE) - this is because there is no NA type for raw, while logicals can be NA.
Fixes failing tests 2006.1, 2006.2, and 2129.
maxType is now initialised as -1, which is not a SEXPTYPE, and the typeorder detection is skipped if the column is NULL. Once looping over all data.tables to rbind, if maxType is still -1 we know that both/all columns are NULL, and to be filled with NA_logical_.
Codecov Report
@@ Coverage Diff @@
## master #4195 +/- ##
==========================================
+ Coverage 99.61% 99.61% +<.01%
==========================================
Files 72 72
Lines 13871 13872 +1
==========================================
+ Hits 13817 13818 +1
Misses 54 54
Continue to review full report at Codecov.
|
8 tasks
TYPEORDER(maxType) where maxType==-1 silently failed
sritchie73
commented
Jan 28, 2020
| # Check rbindlist coercion rules for raw match base R (e.g. using c()) #4172 | ||
| DT1 = data.table(a=as.raw(1), b=as.raw(2), c=as.raw(3), d=as.raw(4), e=as.raw(5), f=as.raw(6), g=as.raw(7), h=as.raw(8)) | ||
| DT2 = data.table(a=as.raw(1), b=TRUE, c=1L, d=1.5, e=complex(real=3, imaginary=1), f="a", g=list(3:5), h=expression(1+1)) | ||
| DT3 = setDT(lapply(names(DT1), function(j) c(DT1[[j]], DT2[[j]]))) |
Contributor
Author
There was a problem hiding this comment.
Noting merge conflict for this test with #4196.
To resolve, replace this line with:
DT3 = data.table(a=c(DT1$a, DT2$a), b=c(DT1$b, DT2$b), c=c(DT1$c, DT2$c),
d=c(DT1$d, DT2$d), e=c(DT1$e, DT2$e), f=c(DT1$f, DT2$f),
g=c(DT1$g, DT2$g), h=c(DT1$h, list(DT2$h)))
(i.e. because in this current PR coercion of any type with expression leads to an expression vector, while PR #4196 expects that column to be coerced to a list)
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #4172
Base R coercion rules mean that raw are coerced to logical, not the other way round:
This PR fixes the typeorder in src/init.c to match the base R coercion rules. This impacts rbindlist, which will now coerce a raw column to a logical column when binding these two together.