Skip to content

Commit 92eee09

Browse files
authored
fix: Complete test coverage and fix errors (#29)
1 parent eac4875 commit 92eee09

20 files changed

+435
-76
lines changed

.covrignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ src/geoarrow.h
33
src/fast_float.h
44
src/d2s.c
55
src/ryu
6+
src/double_parse_fast_float.cc

R/array.R

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,7 @@ as_geoarrow_array_stream.nanoarrow_array_stream <- function(x, ..., schema = NUL
9393
geoarrow_array_from_buffers <- function(schema, buffers) {
9494
schema <- nanoarrow::as_nanoarrow_schema(schema)
9595
extension_name <- schema$metadata[["ARROW:extension:name"]]
96-
if (is.null(extension_name)) {
97-
stop("Expected extension name")
98-
}
96+
stopifnot(!is.null(extension_name))
9997

10098
switch(
10199
extension_name,
@@ -222,14 +220,8 @@ nested_array_from_buffers <- function(schema, buffers, level, validity = NULL) {
222220
validity <- as_validity_buffer(validity)
223221

224222
array <- nanoarrow::nanoarrow_array_init(schema)
225-
226-
if (identical(schema$format, "+l")) {
227-
offsets <- as_offset_buffer(buffers[[1]])
228-
offset_element_size <- 4L
229-
} else {
230-
offsets <- as_large_offset_buffer(buffers[[1]])
231-
offset_element_size <- 8L
232-
}
223+
offsets <- as_offset_buffer(buffers[[1]])
224+
offset_element_size <- 4L
233225

234226
if (offsets$size_bytes == 0) {
235227
return(array)
@@ -295,25 +287,25 @@ as_large_offset_buffer <- function(x) {
295287

296288
as_validity_buffer <- function(x) {
297289
if (is.null(x)) {
298-
return(list(null_count = 0, buffer = NULL))
290+
return(list(null_count = 0L, buffer = NULL))
299291
}
300292

301293
if (inherits(x, "nanoarrow_buffer")) {
302-
return(list(null_count = -1, buffer = x))
294+
return(list(null_count = -1L, buffer = x))
303295
}
304296

305297
if (is.logical(x)) {
306298
null_count <- sum(!x)
307299
} else {
308-
null_count <- sum(x == 0)
300+
null_count <- sum(x == 0L)
309301
}
310302

311303
array <- nanoarrow::as_nanoarrow_array(x, schema = nanoarrow::na_bool())
312304
if (array$null_count > 0) {
313305
stop("NA values are not allowed in validity buffer")
314306
}
315307

316-
list(null_count == null_count, buffer = x$buffers[[2]])
308+
list(null_count = null_count, buffer = array$buffers[[2]])
317309
}
318310

319311
# This really needs a helper in nanoarrow, but for now, we need a way to drop

R/kernel.R

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,7 @@ geoarrow_kernel <- function(kernel_name, input_types, options = NULL) {
7474
}
7575

7676
geoarrow_kernel_push <- function(kernel, args) {
77-
if (!inherits(kernel, "geoarrow_kernel")) {
78-
stop("kernel must inherit from 'geoarrow_kernel'")
79-
}
77+
stopifnot(inherits(kernel, "geoarrow_kernel"))
8078

8179
if (isTRUE(attr(kernel, "is_agg"))) {
8280
array_out <- NULL
@@ -91,9 +89,7 @@ geoarrow_kernel_push <- function(kernel, args) {
9189

9290
args <- lapply(args, nanoarrow::as_nanoarrow_array)
9391
expected_arg_count <- length(attr(kernel, "input_types"))
94-
if (length(args) != expected_arg_count) {
95-
stop(sprintf("Expected %d arguments but got %d", expected_arg_count, length(args)))
96-
}
92+
stopifnot(length(args) == expected_arg_count)
9793

9894
.Call(geoarrow_c_kernel_push, kernel, args, array_out)
9995
array_out
File renamed without changes.

R/nanoarrow-compat.R renamed to R/pkg-nanoarrow.R

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,21 @@
11

2+
# Runs before coverage starts on load
3+
# nocov start
24
register_geoarrow_extension <- function() {
3-
for (ext_name in geoarrow_extension_name_all()) {
5+
all_ext_name <- c(
6+
"geoarrow.wkt", "geoarrow.wkb", "geoarrow.point", "geoarrow.linestring",
7+
"geoarrow.polygon", "geoarrow.multipoint", "geoarrow.mutlilinestring",
8+
"geoarrow.multipolygon"
9+
)
10+
11+
for (ext_name in all_ext_name) {
412
nanoarrow::register_nanoarrow_extension(
513
ext_name,
614
nanoarrow::nanoarrow_extension_spec(subclass = "geoarrow_extension_spec")
715
)
816
}
917
}
18+
# nocov end
1019

1120
#' @importFrom nanoarrow infer_nanoarrow_ptype_extension
1221
#' @export
File renamed without changes.
File renamed without changes.

R/type.R

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,6 @@ na_extension_geoarrow <- function(geometry_type, dimensions = "XY",
6767
na_extension_geoarrow_internal(type_id, crs = crs, edges = edges)
6868
}
6969

70-
geoarrow_extension_name_all <- function() {
71-
c("geoarrow.wkt", "geoarrow.wkb", "geoarrow.point", "geoarrow.linestring",
72-
"geoarrow.polygon", "geoarrow.multipoint", "geoarrow.mutlilinestring",
73-
"geoarrow.multipolygon")
74-
}
75-
7670
#' Inspect a GeoArrow schema
7771
#'
7872
#' @param schema A [nanoarrow_schema][nanoarrow::as_nanoarrow_schema]

src/r-vctr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ SEXP geoarrow_c_vctr_chunk_offsets(SEXP array_list) {
1717
array = (struct ArrowArray*)R_ExternalPtrAddr(VECTOR_ELT(array_list, i));
1818
cumulative_offset += array->length;
1919
if (cumulative_offset > INT_MAX) {
20-
Rf_error("Can't build geoarrow_vctr with length > INT_MAX");
20+
Rf_error("Can't build geoarrow_vctr with length > INT_MAX"); // # nocov
2121
}
2222

2323
offsets[i + 1] = cumulative_offset;

0 commit comments

Comments
 (0)