From a6a72cc4dd0ebb42430bfc79c93c9b4911de5fe1 Mon Sep 17 00:00:00 2001 From: Max Joseph Date: Mon, 6 Mar 2023 14:42:38 -0700 Subject: [PATCH] Better checking of inputs --- DESCRIPTION | 1 + NAMESPACE | 1 + R/find_smap.R | 5 +++-- man/find_smap.Rd | 2 +- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 35a26eb..f4d461d 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -15,6 +15,7 @@ Depends: Imports: hdf5r, httr (>= 1.1.0), + methods, rappdirs (>= 0.3.1), rvest, terra, diff --git a/NAMESPACE b/NAMESPACE index 60497b2..4d2ae36 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -8,6 +8,7 @@ export(set_smap_credentials) importFrom(httr,GET) importFrom(httr,authenticate) importFrom(httr,write_disk) +importFrom(methods,is) importFrom(rappdirs,user_cache_dir) importFrom(terra,crs) importFrom(terra,ext) diff --git a/R/find_smap.R b/R/find_smap.R index ae1d50b..7f2bd19 100644 --- a/R/find_smap.R +++ b/R/find_smap.R @@ -31,7 +31,7 @@ #' #' @param id A character string that refers to a specific SMAP dataset, e.g., #' \code{"SPL4SMGP"} for SMAP L4 Global 3-hourly 9 km Surface and Rootzone Soil -#' Moisture Geophysical Data. See "Details" for a list of supported data types +#' Moisture Geophysical Data. See "Details" for a list of supported data types #' and their associated id codes. #' @param dates An object of class Date or a character string formatted as #' %Y-%m-%d (e.g., "2016-04-01") which specifies the date(s) to search. @@ -57,11 +57,12 @@ #' } #' #' @importFrom httr GET +#' @importFrom methods is #' @export find_smap <- function(id, dates, version) { check_creds() - if (class(dates) != "Date") { + if (!is(dates, "Date")) { dates <- try_make_date(dates) } ensure_dates_in_past(dates) diff --git a/man/find_smap.Rd b/man/find_smap.Rd index 93b933f..e72aec3 100644 --- a/man/find_smap.Rd +++ b/man/find_smap.Rd @@ -9,7 +9,7 @@ find_smap(id, dates, version) \arguments{ \item{id}{A character string that refers to a specific SMAP dataset, e.g., \code{"SPL4SMGP"} for SMAP L4 Global 3-hourly 9 km Surface and Rootzone Soil -Moisture Geophysical Data. See "Details" for a list of supported data types +Moisture Geophysical Data. See "Details" for a list of supported data types and their associated id codes.} \item{dates}{An object of class Date or a character string formatted as