-
Notifications
You must be signed in to change notification settings - Fork 2
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
argument checks for all user facing functions #111
Merged
e-kotov
merged 18 commits into
main
from
23-improve-type-safety-with-rlang-or-assertthat-or-checkmate
Dec 13, 2024
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
e9deb77
Merge pull request #109 from rOpenSpain/main
e-kotov f3d8cd5
argument checks for spod_get
e-kotov 1ff967a
dates not null argument check in spod_download
e-kotov 1ffd2b8
improve info message for out of range dates
e-kotov c4a9f94
argument checks for get_zones
e-kotov 6b8cbcc
argument checks for spod_download
e-kotov 05fb22f
argument checks for convert
e-kotov e2e8209
argument checks for spod_connect
e-kotov 90f36ee
argument checks for spod_disconnect
e-kotov 26cd2bd
argument checks for quick_get
e-kotov 5e3a242
argument checks for spod_codebook
e-kotov eace430
argument checks for spod_available_data
e-kotov 0f2f846
argument checks for spod_get_valid_dates
e-kotov 3c7bfbd
argument checks for spod_set_data_dir
e-kotov 219ed98
argument checks for spod_get_data_dir
e-kotov cf2141c
update docs
e-kotov 404a591
update tests and checks for quick get
e-kotov 34ed5d6
update refs
e-kotov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,10 +52,28 @@ spod_download <- function( | |
return_local_file_paths = FALSE, | ||
ignore_missing_dates = FALSE | ||
) { | ||
# convert english zone names to spanish words used in the default data paths | ||
zones <- match.arg(zones) | ||
|
||
# Validate inputs | ||
checkmate::assert_choice(type, choices = c("od", "origin-destination", "os", "overnight_stays", "nt", "number_of_trips")) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great to see all these additional checks. |
||
checkmate::assert_choice(zones, choices = c( | ||
"districts", "dist", "distr", "distritos", | ||
"municipalities", "muni", "municip", "municipios", | ||
"lua", "large_urban_areas", "gau", "grandes_areas_urbanas" | ||
)) | ||
checkmate::assert_number(max_download_size_gb, lower = 0.1) | ||
checkmate::assert_directory_exists(data_dir, access = "rw") | ||
checkmate::assert_flag(quiet) | ||
checkmate::assert_flag(return_local_file_paths) | ||
checkmate::assert_flag(ignore_missing_dates) | ||
|
||
# normalise zones | ||
zones <- spod_zone_names_en2es(zones) | ||
|
||
# simple null check is enough here, as spod_dates_arugument_to_dates_seq will do additional checks anyway | ||
if (is.null(dates)) { | ||
message("`dates` argument is undefined. Please set `dates='cached_v1'` or `dates='cached_v2'` to convert all data that was previously downloaded. Alternatively, specify at least one date between 2020-02-14 and 2021-05-09 (for v1 data) or between 2022-01-01 onwards (for v2). Any missing data will be downloaded before conversion. For more details on the dates argument, see ?spod_download.") | ||
} | ||
|
||
dates_to_use <- spod_dates_argument_to_dates_seq(dates = dates) | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍