Skip to content
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

Use internal checking function to reduce duplication #161

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

Bisaloo
Copy link
Member

@Bisaloo Bisaloo commented Aug 14, 2024

  • First commit creates an internal function containing checks common to all the cfr_() function
  • Second commit uses a collection so that the input data is completely validated in one go, and an error message with all the issues is returned. This prevents the user from having to try and error multiple times, with a different error message each time.

@Bisaloo Bisaloo requested a review from adamkucharski August 14, 2024 08:35
@adamkucharski
Copy link
Member

Thanks. Will review and merge into the latest 0.1.2 release PR #168 is complete (as seems like this is probably best sequence given CRAN submission was in limbo while this PR was added).

Copy link
Member

@adamkucharski adamkucharski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've reviewed these changes with a mis-specified data input column, i.e. ebola1976_first_30 <- rename(ebola1976_first_30,dates=date) and found the following issue:

The original check format stops at the assert_names step with an informative warning, preventing any further checks being evaluated:

checkmate::assert_names(
colnames(data),
must.include = c("date", "cases", "deaths")
)
Error: Assertion on 'colnames(data)' failed: Names must include the elements {'date','cases','deaths'}, but is missing elements {'date'}.

However, the new function seems to hit an error because it stores the output of this check along the way, but then reaches the assert_data_frame check, which can't be completed:

.check_input_data(data)
Error in `[.data.frame`(data, , c("date", "cases", "deaths")) : 
  undefined columns selected

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants