-
Notifications
You must be signed in to change notification settings - Fork 2
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
Combine two or more specs? #65
Comments
Implementation sketch:
(*) sample: this also allows speeding up the guessing by limiting the maximum number of items to look at. When later a tibblify error occurs, actionable advice would be to increase that threshold. Does this make any sense at all? |
This reminds me a little bit of |
library(tibble)
y <- list(
list(x = 1:2),
list(x = 3:4)
) %>% str()
#> List of 2
#> $ :List of 1
#> ..$ x: int [1:2] 1 2
#> $ :List of 1
#> ..$ x: int [1:2] 3 4
tibble(x = matrix(1:4, ncol = 2))
#> # A tibble: 2 × 1
#> x[,1] [,2]
#> <int> <int>
#> 1 1 3
#> 2 2 4 Created on 2022-06-15 by the reprex package (v2.0.1) To make this work we would have to store the size of the vector in the spec (I was already thinking about this). But when guessing the spec for an object one probably does not want to fix the size for a vector in general. So, this should be an option. Further, I think a matrix row should only be guessed if there are "enough" objects in the object list (say at least 5). So, it might work but this requires some playing around. What do you think? |
I'll have a go at implementing the |
This sounds like a good idea, is it worth starting with a small prototype before changing everything? |
After trying to use |
Do we need a
spec_common()
that takes an arbitrary number of spec objects and computes a common spec?Invariant proposal:
spec_guess(x)
should be the same asspec_common(!!!map(x, spec_guess))
.Would that help get a better understanding of #63?
Created on 2022-06-11 by the reprex package (v2.0.1)
When combining specs, the promotion hierarchy would be clearly unspecified -> chr -> chr_vec.
More broadly: would that enable us to think differently about guessing the spec?
The text was updated successfully, but these errors were encountered: