force class reset in as.data.table.data.frame#6875
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #6875 +/- ##
=======================================
Coverage 98.59% 98.59%
=======================================
Files 79 79
Lines 14661 14665 +4
=======================================
+ Hits 14455 14459 +4
Misses 206 206 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Generated via commit 0e53a5a Download link for the artifact containing the test results: ↓ atime-results.zip
|
|
Not sure how to best mention the regression of #5427 in NEWS 😭 |
Co-authored-by: Michael Chirico <michaelchirico4@gmail.com>
Co-authored-by: Michael Chirico <michaelchirico4@gmail.com>
|
maybe we should just directly call as.data.table.data.frame() after we reun as.data.frame(), just like we run as.data.table.data.table() in the line before, WDYT? |
Good point. We save a dispatch this way :) |
| if (!identical(class(x), "data.frame")) { | ||
| class_orig = class(x) | ||
| x = as.data.frame(x) | ||
| if (identical(class(x), class_orig)) setattr(x, "class", "data.frame") # cater for cases when as.data.frame can generate a loop #6874 | ||
| return(as.data.table.data.frame(x, keep.rownames=keep.rownames, key=key, ...)) | ||
| } |
There was a problem hiding this comment.
What I had in mind is even simpler:
| if (!identical(class(x), "data.frame")) { | |
| class_orig = class(x) | |
| x = as.data.frame(x) | |
| if (identical(class(x), class_orig)) setattr(x, "class", "data.frame") # cater for cases when as.data.frame can generate a loop #6874 | |
| return(as.data.table.data.frame(x, keep.rownames=keep.rownames, key=key, ...)) | |
| } | |
| if (!identical(class(x), "data.frame")) return(as.data.table.data.frame(as.data.frame(x), keep.rownames=keep.rownames, key=key, ...)) |
There was a problem hiding this comment.
but this would put us back to the infinity recursion?
There was a problem hiding this comment.
true true. for my suggestion we'd have to separate the rest of the body into an implementation function and call that to skip the input check at the top. not sure it's that beneficial actually.
MichaelChirico
left a comment
There was a problem hiding this comment.
Please help to cherry-pick this into the patch branch
force class reset in as.data.table.data.frame

Closes #6874