-
Notifications
You must be signed in to change notification settings - Fork 991
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
Fixed typeorder coercion rules for RAWSXP and LGLSXP to match base R #4195
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.
|
TYPEORDER(maxType) where maxType==-1 silently failed
# 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]]))) |
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.
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)
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.