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

vec_c (i.e. also bind_rows) takes the prefix of the first unit rather than auto_scaling (unlike c() which autoscales) #2

Open
sebkopf opened this issue Jan 12, 2025 · 0 comments
Labels
bug Something isn't working wontfix This will not be worked on

Comments

@sebkopf
Copy link
Contributor

sebkopf commented Jan 12, 2025

As far as I can tell there is no way to have vec_c() return autoscaled units because:

  • let's say we're combining x and y
  • vctrs::vec_ptype2 finds the common type between x and y
  • vctrs::vec_cast() casts each x and y independently to the common type determined by vec_ptype2
  • here's the rub: vec_ptype2 DOES not get the whole vectors x and y with the data in it but only the object types (essentially whatever vec_slice(x, 0L) returns)
  • here's the problem then: to determine the ideal auto-scaling for a combined x and y we'd need to have the data so we can calculate the median and decide on the ideal prefix for the combined vector, neither vec_ptype2 nor vec_cast has all the information (vec_ptype2 has the units but not the actual numbers, vec_cast only has the units of one at a time) to do this correctly so I do not see any way for vec_c()/bind_rows to autoscale
  • result: vec_c() can only scale to the ideal prefix of one of the vectors (calculations are correct but autoscaling doesn't work)

Question then: currently c() does autoscale (because it has all the info and thus can) but should this be it's behaviour?? (leads to vec_c() and c() scaling differently)

@sebkopf sebkopf added bug Something isn't working wontfix This will not be worked on labels Jan 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

1 participant