-
Notifications
You must be signed in to change notification settings - Fork 988
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
Add skip_absent to setcolorder #6044
Add skip_absent to setcolorder #6044
Conversation
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.
please revert whitespace changes first to make the diff clearer
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #6044 +/- ##
=======================================
Coverage 98.61% 98.61%
=======================================
Files 79 79
Lines 14536 14536
=======================================
+ Hits 14334 14335 +1
+ Misses 202 201 -1 ☔ View full report in Codecov by Sentry. |
4f95ee1
to
b667257
Compare
Hi @sluga, happy to review but I still see a lot of spurious whitespace diff in R/data.table.R, PTAL |
b667257
to
16ff336
Compare
16ff336
to
0abcb02
Compare
Missed the indent change. Might not be a bad idea to include a .Rproj file with the correct whitespace config in the repo; I assume at least some contributors use RStudio, and I don't think the file would be a problem for those who don't use RStudio. |
Thanks for the suggestion. Those files are ignored: Lines 23 to 24 in 585ec52
As are several related to other IDEs like Emacs. Better might be putting in the .dev folder, like our recommended .Rprofile: https://github.com/Rdatatable/data.table/blob/master/.dev/.Rprofile There users can get a copy when cloning the repo and just copy it to the package directory. I am using VScode these days so not sure what an Rproj looks like anymore. |
LGTM, please add a NEWS bullet |
Thanks! Let's merge #6068 first since it's basically ready, then would you mind quickly refactoring this PR to use the new functionality? |
OK, #6068 is merged, would you like to have a go at using the new argument to |
c76d7da
to
67979e3
Compare
@MichaelChirico Hmm, the tests I added for this feature pass after the update, but test 1967.63 fails:
|
inst/tests/tests.Rraw
Outdated
test(498.11, setcolorder(DT, c('d', 'c', 'b', 'a'), skip_absent=TRUE), data.table(c=3, b=2, a=1)) | ||
test(498.12, setcolorder(DT, 4:1), error='non-existing column') | ||
test(498.13, setcolorder(DT, 4:1, skip_absent=TRUE), data.table(a=1, b=2, c=3)) | ||
test(498.14, setcolorder(DT, c(1, 1, 2, 3), skip_absent=TRUE), error='!=') |
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.
Please add a test for setcolorder(DT, c('a', 'b', 'd'), skip_absent=TRUE)
.
The NEWS item currently reads like 'c' will be dropped from the output, which would be bad -- I would expect the above to be equivalent to setcolorder(DT, c("a", "b"))
.
Hi @sluga I think this is near complete, just the last ask for a new test if you don't mind & we can merge. Thanks! |
Sorry for the wait @MichaelChirico, added tests & revised NEWS & help slightly. |
Thanks @sluga LGTM! I've invited you to become a project Member -- that means you can create branches directly on this repo for future contributions which will facilitate collaboration. I added you as contributor to the DESCRIPTION using your name as written here: Please feel free to file a follow-up PR with any correction! |
Motivation: I sometimes want to ensure a certain order of columns but the set of columns is not fixed, i.e. a given column may or may not be present.
Now, working around that is trivial & so the benefit of this new argument isn't large, but it would be a small quality of life improvement & furthermore
setnames
already has theskip_absent
argument, so it feels appropriate to add it tosetcolorder
as well.