-
Notifications
You must be signed in to change notification settings - Fork 283
Use vctrs coercions #914
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
Use vctrs coercions #914
Conversation
|
I've now implemented the remaining pieces. See news for details. The error messages could certainly be improved, but I think that's worth implementing in a separate PR. |
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.
We would switch to vec_cast() in a second step right?
I think we may need to provide an edition or a legacy global option to keep supporting existing scripts that these changes will break. Maybe we should keep the existing code as is and provide a vctrs default path?
|
For now, should deprecate character coercions rather than eliminating them all together. |
| if (i == 0) | ||
| deprecate_to_char("logical"); |
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.
@lionel- This is a bit of a hack because I want to deprecate aggressively so deprecate_to_char() uses always = TRUE and then I only call it for the first element. There's some small risk that the deprecation message won't get generated if the transformation is not type stable (e.g. map_chr(list("x", 1), identity)) but I think it's worth taking that small risk is return for much simpler code.
| * `map_dbl(1.5, identity)` now fails because we believe that silently | ||
| truncating doubles to integers is dangerous. But note that | ||
| `map_dbl(1, identity)` still works since no numeric precision is lost. |
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.
Isn't this map_int() in both examples here?
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.
Ooops yes.
| deprecate_to_char <- function(type) { | ||
| lifecycle::deprecate_warn( | ||
| "0.4.0", | ||
| I(paste0("Automatical coercion from ", type, " to character")), |
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.
Automatic not Automatical?
So far have just removed coercions that vctrs doesn't support, which breaks ~15 packages.
Fixes #904