Skip to content

Commit

Permalink
Changes to the scales/list endpoint
Browse files Browse the repository at this point in the history
At least one parameter must be specified now.
  • Loading branch information
castroinsua committed Sep 3, 2024
1 parent 84e7f3d commit fec066e
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 20 deletions.
2 changes: 0 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ URL: https://docs.ropensci.org/paleobioDB/,
BugReports: https://github.com/ropensci/paleobioDB/issues
Imports:
curl,
graphics,
grDevices,
gtools,
maps,
rjson,
Expand Down
12 changes: 6 additions & 6 deletions R/pbdb_geographic_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@
#' in the map.
#' @param do_plot Logical. If `TRUE`, the function produces a plot in
#' addition to returning a data frame with the occurrence counts.
#' @param ... Other parameters. See [par()] and [map()].
#' @param ... Other parameters. See [par()] and [maps::map()].
#' @details The argument `show = "coords"` in the [pbdb_occurrences()]
#' function is required. We recommend the use of a cairo device
#' ([X11()]) for better visualization of the maps. See Examples.
#' @returns A data frame with the number of occurrences per
#' coordinate.
#' @seealso See [pbdb_occurrences()], [map()], [par()] and [colors()]
#' @seealso See [pbdb_occurrences()], [maps::map()], [par()] and [colors()]
#' help pages.
#' @export
#' @examples \dontrun{
Expand Down Expand Up @@ -173,7 +173,7 @@ pbdb_map <- function(data, col_int = "white", pch = 19, col_ocean = "black",
#' map.
#' @param do_plot Logical. If `TRUE`, the function produces a plot in
#' addition to returning a `SpatRaster`.
#' @param ... Other parameters. See [par()] and [map()]
#' @param ... Other parameters. See [par()] and [maps::map()]
#' @details The argument `show = "coords"` in the [pbdb_occurrences()]
#' function is required. We recommend the use of a cairo device
#' ([X11()]) for better visualization of the maps. See Examples.
Expand All @@ -182,7 +182,7 @@ pbdb_map <- function(data, col_int = "white", pch = 19, col_ocean = "black",
#' resolution that was specified in the `res` argument. The default
#' is `res = 5`. Users that wish to work with objects of this type
#' should load package `terra`.
#' @seealso See [pbdb_occurrences()], [map()], [par()] and [colors()]
#' @seealso See [pbdb_occurrences()], [maps::map()], [par()] and [colors()]
#' help pages
#' @export
#' @examples \dontrun{
Expand Down Expand Up @@ -314,7 +314,7 @@ pbdb_map_occur <- function(data,
#' colour gradient showing the richness per cell in the map.
#' @param title A title for the plot, to be positioned to the right of
#' the legend.
#' @param ... Other parameters. See [par()] and [map()].
#' @param ... Other parameters. See [par()] and [maps::map()].
#' @details The argument `show = c("coords", "classext")` in the
#' [pbdb_occurrences()] function is required. We recommend the use
#' of a cairo device ([X11()]) for better visualization of the
Expand All @@ -324,7 +324,7 @@ pbdb_map_occur <- function(data,
#' that was specified in the `res` argument. The default is `res =
#' 5`. Users that wish to work with objects of this type should load
#' package `terra`.
#' @seealso See [pbdb_occurrences()], [map()], [par()] and [colors()]
#' @seealso See [pbdb_occurrences()], [maps::map()], [par()] and [colors()]
#' help pages.
#' @export
#' @examples \dontrun{
Expand Down
11 changes: 10 additions & 1 deletion R/pbdb_queries.R
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,15 @@ pbdb_scale <- function(id, ...) {
#' documentation for accepted parameters at
#' <https://paleobiodb.org/data1.2/scales/list>. E.g.:
#'
#' * `all_records`: Set to `TRUE` to list all intervals.
#'
#' * `id`: Return only time scales with the specified
#' identifier(s). It is possible to provide multiple identifiers as
#' a comma-separated list.
#'
#' * `name`: Return only time scales with the specified name(s). It is
#' possible to provide multiple names as a comma-separated list.
#'
#' * `vocab`: Set to `"pbdb"` to show the complete name of the
#' variables (by default variables have short 3-letter names).
#'
Expand All @@ -534,7 +543,7 @@ pbdb_scale <- function(id, ...) {
#' @examples \dontrun{
#' ## Get a data frame with all the scales available in PBDB
#' ## by setting no ids
#' pbdb_scales()
#' pbdb_scales(all_records = TRUE)
#' }
pbdb_scales <- function(...) {
l <- list(...)
Expand Down
4 changes: 2 additions & 2 deletions man/pbdb_map.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/pbdb_map_occur.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/pbdb_map_richness.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion man/pbdb_scales.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions tests/testthat/test-queries_intervals_scales.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ test_that("pbdb_scale() returns a data frame with an id column", {
expect_equal(nrow(response), 1)
})

test_that("multivalue elements are converted to a string with semicolons", {
test_that("pbdb_scales() returns a data frame with an id column", {
skip_if_offline("paleobiodb.org")
response <- pbdb_scales()
expect_true("lvs" %in% names(response))
expect_true(all(grepl(";", response$lvs)))
response <- pbdb_scales(all_records = TRUE)
expect_s3_class(response, "data.frame")
expect_true("oid" %in% names(response))
expect_gt(nrow(response), 1)
})

0 comments on commit fec066e

Please sign in to comment.