Skip to content
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

Bug with 0-col data frames in vec_order_info() affecting vec_rank() #1863

Closed
DavisVaughan opened this issue Aug 2, 2023 · 1 comment · Fixed by #1866
Closed

Bug with 0-col data frames in vec_order_info() affecting vec_rank() #1863

DavisVaughan opened this issue Aug 2, 2023 · 1 comment · Fixed by #1866
Labels
bug an unexpected problem or unintended behavior op:sort type:dataframe

Comments

@DavisVaughan
Copy link
Member

DavisVaughan commented Aug 2, 2023

From tidyverse/dplyr#6899

> vctrs::vec_rank(data.frame(row.names = 1:10))
 [1] 2037149796 1075052658          0          0          0  470093824 2037149796 1075052658          0          0

Probably from

> vctrs:::vec_order_info(data.frame(row.names = 1:10))
[[1]]
 [1]  1  2  3  4  5  6  7  8  9 10

[[2]]
integer(0)

[[3]]
[1] 0

Where the 2nd slot is supposed to hold the group sizes?

I think the 2nd slot should just hold a 10? i.e. all rows are the same? Not 100% sure but seems consistent with our treatment of 0 col data frames in vec_equal() and elsewhere

@DavisVaughan
Copy link
Member Author

DavisVaughan commented Aug 2, 2023

Probably need to do something like "push group size equivalent to data frame size" in this 0 column special case here

vctrs/src/order.c

Lines 3971 to 3975 in e88a3e2

// Special case no columns
if (n_cols == 0) {
init_order(p_order);
return;
}

i.e. groups_size_maybe_push(size, p_group_infos);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior op:sort type:dataframe
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant