-
-
Notifications
You must be signed in to change notification settings - Fork 7
Make as card check format #534
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
base: main
Are you sure you want to change the base?
Conversation
|
✅ All contributors have signed the CLA |
|
I have read the CLA Document and I hereby sign the CLA |
087a156 to
f4f5ec2
Compare
| # Check whether expected columns are present --------------------------------- | ||
|
|
||
|
|
||
|
|
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.
I think it is missing something
| .message_or_error( | ||
| "The following columns are expected to be list columns: {.val {not_a_lst_columns}}.", | ||
| error = error_on_fail, | ||
| envir = environment() |
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.
is this needed if default is rlang::current_env()?
| return(out) | ||
|
|
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.
| return(out) | |
| out |
|
|
||
| # check in inputs ------------------------------------------------------------ | ||
| check_class(x, cls = "data.frame") | ||
|
|
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.
| check_scalar_logical(check) | |
| expect_no_error( | ||
| check_ard_structure(data.frame(badname = 3)) | ||
| ) |
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.
| expect_no_error( | |
| check_ard_structure(data.frame(badname = 3)) | |
| ) | |
| expect_no_error( | |
| check_ard_structure(data.frame(badname = 3)) | |
| ) |
| ) | ||
| }) | ||
|
|
||
|
|
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.
| #' cards:::..warn_or_error("This will be a message", FALSE) | ||
| #' cards:::..warn_or_error("This will be an error", TRUE) |
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.
this should be message_or_error right?
|
|
||
| #' Message or error | ||
| #' | ||
| #' Either error or message depending on input |
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.
| #' Either error or message depending on input | |
| #' Either error or message depending on input. |
| #' @param msg (scalar `character`)\cr | ||
| #' Error message | ||
| #' @param error (scalar `logical`)\cr | ||
| #' If this should produce an error or a warning. FALSE by default |
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.
| #' If this should produce an error or a warning. FALSE by default | |
| #' If this should produce an error or a warning. FALSE by default |
| #' Environment to evaluate the glue expressions in passed in `cli::cli_abort(message)`. | ||
| #' Default is `rlang::current_env()` | ||
| #' @inheritParams cli::cli_abort | ||
| #' @return Invisible NULL |
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.
I am not sure this is needed. Also it is internal
| return(invisible()) | ||
|
|
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.
| return(invisible()) |
Maybe without this completely?
|
|
||
| } | ||
|
|
||
|
|
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.
Resolves #514
Incorportating
check_ard_structureintoas_cardproved to not be straight forwards asas_cardis used throughout the code base to coerce objects into a card class that do not pass the checks incheck_ard_structure.For now at least I did the following
check_ard_structurecan either error or warn based on user input. I made a function to switch between these (I couldn't see any function which existed to do this already). Part of me wonders about allowing the user a bit more control over what it considers an error or a warning; they can switch off caring about the column order, and whether there is a methods entry, but maybe we could allow more in future. That said I think it's probably better as a binary switch for a changeas_card, there is now an argument for whether you want to check if a card follows this structure. At the moment this defaults to TRUE, but if you think this is too strong I could switch it to default FALSE. Doing that would be the most low impact change.