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

Fix unspecified fallback #1112

Merged
merged 5 commits into from
May 23, 2020
Merged

Conversation

lionel-
Copy link
Member

@lionel- lionel- commented May 21, 2020

Branched from #1111.

This adds support for combining unspecified chunks to the base::c() fallback. We can't rely on c() for this because implementations might not handle unspecified inputs, and if unspecified is the first input this would prevent dispatch from reaching the expected method. Instead, we first combine non-unspecified chunks, then use [ with NA integer locations to expand the result with missing values.

With this change, the fallback is now consistent when disjoint data frames are binded:

x <- sf::st_sfc(sf::st_point(1:2))
y <- sf::st_sfc(sf::st_multipoint(matrix(1:4, 2)), sf::st_multipoint(matrix(5:8, 2)))

vec_rbind(
  data_frame(x = x),
  data_frame(y = y)
)
#>             x                         y
#> 1 POINT (1 2)          MULTIPOINT EMPTY
#> 2 POINT EMPTY MULTIPOINT ((1 3), (2 4))
#> 3 POINT EMPTY MULTIPOINT ((5 7), (6 8))

@lionel- lionel- changed the base branch from fix-fallback-rbind to master May 22, 2020 14:40
Copy link
Member

@DavisVaughan DavisVaughan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like in #1111, I assume vec-unchop support will come later?

src/type2.c Outdated Show resolved Hide resolved
Co-authored-by: Davis Vaughan <davis@rstudio.com>
@lionel-
Copy link
Member Author

lionel- commented May 23, 2020

Like in #1111, I assume vec-unchop support will come later?

Yes, this might be a bit tricky with the indices.

@lionel- lionel- merged commit b3c6aa8 into r-lib:master May 23, 2020
@lionel- lionel- deleted the fix-unspecified-fallback branch May 23, 2020 03:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants