-
Notifications
You must be signed in to change notification settings - Fork 990
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
setDT() works on S4 slots (again), and := works in under-allocated S4 slots #6703
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #6703 +/- ##
=======================================
Coverage 98.61% 98.61%
=======================================
Files 79 79
Lines 14553 14561 +8
=======================================
+ Hits 14352 14360 +8
Misses 201 201 ☔ View full report in Codecov by Sentry. |
Generated via commit eeeb61c Download link for the artifact containing the test results: ↓ atime-results.zip
|
@@ -3048,6 +3052,9 @@ rleidv = function(x, cols=seq_along(x), prefix=NULL) { | |||
is.name(e[[1L]]) && is.name(e[[2L]]) # e.g. V1:V2, but not min(V1):max(V2) or 1:max(V2) | |||
} | |||
|
|||
# for assignments like x[[1]][, a := 2] or setDT(x@DT) | |||
.is_simple_extraction = function(e) e %iscall% c('$', '@', '[[') && is.name(e[[2L]]) |
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.
great thanks for adding this helper fun
lgtm but I don't really use S4 very often... |
nor do i... basically relying on sandboxing, existing tests, and revdeps here. |
Closes #6701 (and possibly #6575). Closes #6704.
Lumped together because of #6702 -- really this should be one small change fixing both places. After #6702 it will only be possible for a bug to affect both call sites of
.is_simple_extraction()
.I'm not totally clear what broke exactly -- something about the change to
.shallow()
broke assignment back to an S4 slot.On a side note, I'm not totally clear this should be allowed in the first place -- it really bends S4 semantics IMO.
For example, if we try and pass a
data.table
to a class's slot which is declared asdata.frame
, S4 will coerce it to data.frame:Glancing at the one downstream I debugged, personally I think they should change the code:
https://github.com/HimesGroup/snpsettest/blob/38d5b86217fcd9061e3714bf911eb4ffb36ea1b3/R/harmonize_sumstats.R#L83-L88
setDT()
there is having global effects perhaps unintentionally. Something likesnps = as.data.table(x@snps)
seems more appropriate.Anyway, that's a thought for another day.