-
Notifications
You must be signed in to change notification settings - Fork 71
Always apply specialized proxy methods recursively over data frames #1664
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
Always apply specialized proxy methods recursively over data frames #1664
Conversation
|
It feels like we could make it simpler by recursively proxying data frame proxies from the generics? Then the rcrd methods only need to call |
|
Would that mean we remove the special data frame methods (like the one below) and let data frames fall through to > vec_proxy_equal.data.frame
function(x, ...) {
df_proxy(x, VCTRS_PROXY_KIND_equal)
}And then internally we'd say something like r_obj* vec_proxy_equal(r_obj* x) {
r_obj* method = KEEP(vec_proxy_equal_method(x));
r_obj* out = KEEP(vec_proxy_equal_invoke(x, method));
if (is_data_frame(out)) {
# Apply proxy recursively if the proxy is a data frame
out = df_proxy(out, VCTRS_PROXY_KIND_equal)
}
FREE(2);
return out;
}Noting that I still don't think we'd do this automatic recursion for |
|
yep something like that |
|
Ok, this PR now removes all of the specialized methods for data frames and record vectors, and instead relies on the fact that:
I think this is nice because someone could, in theory, return a complicated data frame containing a df-col from their custom Revdepcheck |
99e1cd6 to
d570de3
Compare
vec_proxy_compare() and vec_proxy_order() rcrd methods
lionel-
left a comment
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.
Looks like a great improvement.
Required because now there is a `vec_proxy_order.vctrs_rcrd()` method that would otherwise sit in front of the `vec_proxy_compare.vctrs_rational()` method
This allows us to remove the data frame and record methods: - Data frames return themselves as the proxy by default, which is then automatically recursively proxied - Records fall through to `vec_proxy.vctrs_rcrd()`, which returns a data frame that is then proxied recursively
d570de3 to
5fc4d6c
Compare
Follow up to #1537
That PR implemented:
but that means that if
vec_proxy_order/compare()for a rcrd class fall through to this, thenvec_proxy_equal()will be called on each field, which isn't right.To fix that, we need
vec_proxy_order/compare()methods specifically forvctrs_rcrdwhich call their corresponding function internally after creating a data frame.This requires tweaking the vctrs-rational class, because it relied on the
vec_proxy_compare.vctrs_rational()method being run whensort(x)was called, but this is no longer the case because the newvec_proxy_order.vctrs_rcrd()method intercepts it instead.