Skip to content

Commit

Permalink
fix data frame dep
Browse files Browse the repository at this point in the history
  • Loading branch information
paleolimbot committed Dec 13, 2023
1 parent 5cbff1a commit 63cb4d0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
3 changes: 1 addition & 2 deletions r/geoarrow/DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ Suggests:
arrow,
R6,
sf,
testthat (>= 3.0.0),
tibble
testthat (>= 3.0.0)
Remotes:
nanoarrow=apache/arrow-nanoarrow/r
3 changes: 2 additions & 1 deletion r/geoarrow/R/sf-compat.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ st_as_sfc.Array <- function(x, ..., promote_multi = FALSE) {
}

st_as_sf.ArrowTabular <- function(x, ..., promote_multi = FALSE) {
df <- tibble::as_tibble(x)
# Some Arrow as.data.frame() methods still return tibbles
df <- as.data.frame(as.data.frame(x))
is_geom <- vapply(df, inherits, logical(1), "geoarrow_vctr")
df[is_geom] <- lapply(df[is_geom], sf::st_as_sfc, promote_multi = promote_multi)
sf::st_as_sf(df, ...)
Expand Down
10 changes: 5 additions & 5 deletions r/geoarrow/tests/testthat/test-sf-compat.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ test_that("arrow package objects can be converted to and from sf objects", {
skip_if_not_installed("arrow")

sfc <- sf::st_sfc(sf::st_point(c(0, 1)))
sf <- sf::st_as_sf(tibble::tibble(geometry = sfc))
sf <- sf::st_as_sf(data.frame(geometry = sfc))
vctr <- as_geoarrow_vctr(wk::wkt("POINT (0 1)"))
array <- arrow::as_arrow_array(vctr)
chunked <- arrow::as_chunked_array(array)
Expand All @@ -30,19 +30,19 @@ test_that("arrow package objects can be converted to and from sf objects", {
expect_identical(sf::st_as_sfc(chunked), sfc)
expect_identical(
sf::st_as_sf(table),
sf::st_as_sf(tibble::tibble(geometry = sfc))
sf
)
expect_identical(
sf::st_as_sf(dataset),
sf::st_as_sf(tibble::tibble(geometry = sfc))
sf
)
expect_identical(
sf::st_as_sf(scanner),
sf::st_as_sf(tibble::tibble(geometry = sfc))
sf
)
expect_identical(
sf::st_as_sf(reader),
sf::st_as_sf(tibble::tibble(geometry = sfc))
sf
)

chunked2 <- arrow::as_chunked_array(sfc, type = arrow::as_data_type(na_extension_wkt()))
Expand Down

0 comments on commit 63cb4d0

Please sign in to comment.