diff --git a/NEWS.md b/NEWS.md index 8ec1569aa..f59e680c2 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,7 @@ # pointblank (development version) +- The `regex` argument of `col_vals_regex()` (and its `expect_*`/`test_*` variants) is renamed to `pattern` to align with Python pointblank. The old `regex` argument remains accepted but emits a soft-deprecation warning. YAML files using a `regex:` key are still read correctly; newly written YAML uses `pattern:`. (#685) + - `col_vals_gte()` and `col_vals_lte()` are renamed to `col_vals_ge()` and `col_vals_le()` to align with Python pointblank naming. The old names remain as soft-deprecated aliases and will continue to work for the foreseeable future. Existing YAML files using `col_vals_gte`/`col_vals_lte` step keys are still accepted. (#684) - The `stop` and `notify` threshold levels in `action_levels()` are renamed to `error` and `critical` (aligning with Python pointblank), with deprecation warnings for old names; `action_fns()` is now exported. (#611) diff --git a/R/all_passed.R b/R/all_passed.R index 42998106a..a65266465 100644 --- a/R/all_passed.R +++ b/R/all_passed.R @@ -78,7 +78,7 @@ #' agent <- #' create_agent(tbl = tbl) |> #' col_vals_gt(columns = a, value = 3) |> -#' col_vals_lte(columns = a, value = 10) |> +#' col_vals_le(columns = a, value = 10) |> #' col_vals_increasing(columns = a) |> #' interrogate() #' ``` diff --git a/R/col_vals_between.R b/R/col_vals_between.R index 7566ec602..3feb55a8f 100644 --- a/R/col_vals_between.R +++ b/R/col_vals_between.R @@ -33,7 +33,7 @@ #' and `right`, states whether each bound is inclusive or not. The default is #' `c(TRUE, TRUE)`, where both endpoints are inclusive (i.e., `[left, right]`). #' For partially-unbounded versions of this function, we can use the -#' [col_vals_lt()], [col_vals_lte()], [col_vals_gt()], or [col_vals_gte()] +#' [col_vals_lt()], [col_vals_le()], [col_vals_gt()], or [col_vals_ge()] #' validation functions. The validation function can be used directly on a data #' table or with an *agent* object (technically, a `ptblank_agent` object) #' whereas the expectation and test functions can only be used with a data diff --git a/R/col_vals_not_between.R b/R/col_vals_not_between.R index 9a919f849..e1d31099e 100644 --- a/R/col_vals_not_between.R +++ b/R/col_vals_not_between.R @@ -34,7 +34,7 @@ #' states whether each bound is inclusive or not. The default is `c(TRUE, #' TRUE)`, where both endpoints are inclusive (i.e., `[left, right]`). For #' partially-unbounded versions of this function, we can use the -#' [col_vals_lt()], [col_vals_lte()], [col_vals_gt()], or [col_vals_gte()] +#' [col_vals_lt()], [col_vals_le()], [col_vals_gt()], or [col_vals_ge()] #' validation functions. The validation function can be used directly on a data #' table or with an *agent* object (technically, a `ptblank_agent` object) #' whereas the expectation and test functions can only be used with a data diff --git a/R/col_vals_regex.R b/R/col_vals_regex.R index e5f965509..1d5fe04f1 100644 --- a/R/col_vals_regex.R +++ b/R/col_vals_regex.R @@ -25,9 +25,9 @@ #' #' The `col_vals_regex()` validation function, the `expect_col_vals_regex()` #' expectation function, and the `test_col_vals_regex()` test function all check -#' whether column values in a table correspond to a `regex` matching expression. -#' The validation function can be used directly on a data table or with an -#' *agent* object (technically, a `ptblank_agent` object) whereas the +#' whether column values in a table correspond to a `pattern` matching +#' expression. The validation function can be used directly on a data table or +#' with an *agent* object (technically, a `ptblank_agent` object) whereas the #' expectation and test functions can only be used with a data table. Each #' validation step or expectation will operate over the number of test units #' that is equal to the number of rows in the table (after any `preconditions` @@ -35,13 +35,20 @@ #' #' @inheritParams col_vals_gt #' -#' @param regex *Regex pattern* +#' @param pattern *Regex pattern* #' #' `scalar` // **required** #' #' A regular expression pattern to test for a match to the target column. Any #' regex matches to values in the target `columns` will pass validation. #' +#' @param regex `r lifecycle::badge("deprecated")` +#' +#' `scalar` // **deprecated** +#' +#' Deprecated in favor of `pattern`. Providing a value here will work but +#' will emit a warning asking you to switch to `pattern`. +#' #' @return For the validation function, the return value is either a #' `ptblank_agent` object or a table object (depending on whether an agent #' object or a table was passed to `x`). The expectation function invisibly @@ -187,11 +194,11 @@ #' #' R statement: #' -#' ``` +#' ```r #' agent |> #' col_vals_regex( #' columns = a, -#' regex = "[0-9]-[a-z]{3}-[0-9]{3}", +#' pattern = "[0-9]-[a-z]{3}-[0-9]{3}", #' na_pass = TRUE, #' preconditions = \(x) x |> dplyr::filter(a < 10), #' segments = b ~ c("group_1", "group_2"), @@ -207,7 +214,7 @@ #' steps: #' - col_vals_regex: #' columns: c(a) -#' regex: '[0-9]-[a-z]{3}-[0-9]{3}' +#' pattern: '[0-9]-[a-z]{3}-[0-9]{3}' #' na_pass: true #' preconditions: ~. %>% dplyr::filter(a < 10) #' segments: b ~ c("group_1", "group_2") @@ -219,12 +226,15 @@ #' ``` #' #' In practice, both of these will often be shorter as only the `columns` and -#' `regex` arguments require values. Arguments with default values won't be +#' `pattern` arguments require values. Arguments with default values won't be #' written to YAML when using [yaml_write()] (though it is acceptable to include #' them with their default when generating the YAML by other means). It is also #' possible to preview the transformation of an agent to YAML without any #' writing to disk by using the [yaml_agent_string()] function. #' +#' Note that YAML files previously written with a `regex:` key are still +#' accepted — the value will be used as the `pattern`. +#' #' @section Examples: #' #' The `small_table` dataset in the package has a character-based `b` column @@ -250,7 +260,7 @@ #' ```r #' agent <- #' create_agent(tbl = small_table) |> -#' col_vals_regex(columns = b, regex = pattern) |> +#' col_vals_regex(columns = b, pattern = pattern) |> #' interrogate() #' ``` #' @@ -272,7 +282,7 @@ #' #' ```{r} #' small_table |> -#' col_vals_regex(columns = b, regex = pattern) |> +#' col_vals_regex(columns = b, pattern = pattern) |> #' dplyr::slice(1:5) #' ``` #' @@ -282,7 +292,7 @@ #' time. This is primarily used in **testthat** tests. #' #' ```r -#' expect_col_vals_regex(small_table, columns = b, regex = pattern) +#' expect_col_vals_regex(small_table, columns = b, pattern = pattern) #' ``` #' #' ## D: Using the test function @@ -291,7 +301,7 @@ #' us. #' #' ```{r} -#' small_table |> test_col_vals_regex(columns = b, regex = pattern) +#' small_table |> test_col_vals_regex(columns = b, pattern = pattern) #' ``` #' #' @family validation functions @@ -307,7 +317,7 @@ NULL col_vals_regex <- function( x, columns, - regex, + pattern, na_pass = FALSE, preconditions = NULL, segments = NULL, @@ -315,9 +325,26 @@ col_vals_regex <- function( step_id = NULL, label = NULL, brief = NULL, - active = TRUE + active = TRUE, + regex = NULL ) { + # Handle deprecated `regex` argument + if (!is.null(regex)) { + rlang::warn( + c( + "The `regex` argument of `col_vals_regex()` is deprecated.", + "i" = "Please use `pattern` instead." + ), + class = "pointblank_soft_deprecated", + .frequency = "once", + .frequency_id = "pointblank-col_vals_regex-regex-deprecation" + ) + if (missing(pattern)) { + pattern <- regex + } + } + # Capture the `columns` expression columns <- rlang::enquo(columns) # Get `columns` as a label @@ -340,7 +367,7 @@ col_vals_regex <- function( create_agent(x, label = "::QUIET::") |> col_vals_regex( columns = tidyselect::all_of(columns), - regex = regex, + pattern = pattern, na_pass = na_pass, preconditions = preconditions, segments = segments, @@ -359,7 +386,7 @@ col_vals_regex <- function( brief <- resolve_brief( brief = brief, agent = agent, columns = columns, segments_list = segments_list, - preconditions = preconditions, values = regex, + preconditions = preconditions, values = pattern, assertion_type = "col_vals_regex" ) @@ -389,7 +416,7 @@ col_vals_regex <- function( i_o = i_o, columns_expr = columns_expr, column = columns[i], - values = regex, + values = pattern, na_pass = na_pass, preconditions = preconditions, seg_expr = segments, @@ -413,19 +440,36 @@ col_vals_regex <- function( expect_col_vals_regex <- function( object, columns, - regex, + pattern, na_pass = FALSE, preconditions = NULL, - threshold = 1 + threshold = 1, + regex = NULL ) { + # Handle deprecated `regex` argument + if (!is.null(regex)) { + rlang::warn( + c( + "The `regex` argument of `expect_col_vals_regex()` is deprecated.", + "i" = "Please use `pattern` instead." + ), + class = "pointblank_soft_deprecated", + .frequency = "once", + .frequency_id = "pointblank-expect_col_vals_regex-regex-deprecation" + ) + if (missing(pattern)) { + pattern <- regex + } + } + fn_name <- "expect_col_vals_regex" vs <- create_agent(tbl = object, label = "::QUIET::") |> col_vals_regex( columns = {{ columns }}, - regex = {{ regex }}, + pattern = pattern, na_pass = na_pass, preconditions = {{ preconditions }}, actions = action_levels(critical = threshold) @@ -495,17 +539,34 @@ expect_col_vals_regex <- function( test_col_vals_regex <- function( object, columns, - regex, + pattern, na_pass = FALSE, preconditions = NULL, - threshold = 1 + threshold = 1, + regex = NULL ) { + # Handle deprecated `regex` argument + if (!is.null(regex)) { + rlang::warn( + c( + "The `regex` argument of `test_col_vals_regex()` is deprecated.", + "i" = "Please use `pattern` instead." + ), + class = "pointblank_soft_deprecated", + .frequency = "once", + .frequency_id = "pointblank-test_col_vals_regex-regex-deprecation" + ) + if (missing(pattern)) { + pattern <- regex + } + } + vs <- create_agent(tbl = object, label = "::QUIET::") |> col_vals_regex( columns = {{ columns }}, - regex = {{ regex }}, + pattern = pattern, na_pass = na_pass, preconditions = {{ preconditions }}, actions = action_levels(critical = threshold) diff --git a/R/col_vals_str_len.R b/R/col_vals_str_len.R index bc45925f9..44a714d63 100644 --- a/R/col_vals_str_len.R +++ b/R/col_vals_str_len.R @@ -224,7 +224,7 @@ expect_col_vals_str_len <- function( max = max, na_pass = na_pass, preconditions = {{ preconditions }}, - actions = action_levels(notify_at = threshold) + actions = action_levels(critical = threshold) ) |> interrogate() |> (\(x) x$validation_set)() @@ -303,7 +303,7 @@ test_col_vals_str_len <- function( max = max, na_pass = na_pass, preconditions = {{ preconditions }}, - actions = action_levels(notify_at = threshold) + actions = action_levels(critical = threshold) ) |> interrogate() |> (\(x) x$validation_set)() diff --git a/R/conjointly.R b/R/conjointly.R index afcafd430..e25089782 100644 --- a/R/conjointly.R +++ b/R/conjointly.R @@ -54,7 +54,7 @@ #' A collection one-sided formulas that consist of validation functions that #' validate row units (the `col_vals_*()` series), column existence #' ([col_exists()]), or column type (the `col_is_*()` series). An example of -#' this is `~ col_vals_gte(., a, 5.5), ~ col_vals_not_null(., b`). +#' this is `~ col_vals_ge(., a, 5.5), ~ col_vals_not_null(., b`). #' #' @param .list *Alternative to `...`* #' diff --git a/R/create_agent.R b/R/create_agent.R index e007bb705..f42f48a80 100644 --- a/R/create_agent.R +++ b/R/create_agent.R @@ -401,7 +401,7 @@ #' ) |> #' rows_distinct() |> #' col_vals_gt(columns = d, value = 100) |> -#' col_vals_lte(columns = c, value = 5) |> +#' col_vals_le(columns = c, value = 5) |> #' col_vals_between( #' columns = c, #' left = vars(a), right = vars(d), diff --git a/R/object_ops.R b/R/object_ops.R index 5a7349d3d..439b90559 100644 --- a/R/object_ops.R +++ b/R/object_ops.R @@ -136,11 +136,11 @@ #' col_exists(columns = c(date, date_time)) |> #' col_vals_regex( #' columns = b, -#' regex = "[0-9]-[a-z]{3}-[0-9]{3}" +#' pattern = "[0-9]-[a-z]{3}-[0-9]{3}" #' ) |> #' rows_distinct() |> #' col_vals_gt(columns = d, value = 100) |> -#' col_vals_lte(columns = c, value = 5) |> +#' col_vals_le(columns = c, value = 5) |> #' interrogate() #' ``` #' @@ -614,11 +614,11 @@ x_read_disk <- function( #' col_exists(columns = c(date, date_time)) |> #' col_vals_regex( #' columns = b, -#' regex = "[0-9]-[a-z]{3}-[0-9]{3}" +#' pattern = "[0-9]-[a-z]{3}-[0-9]{3}" #' ) |> #' rows_distinct() |> #' col_vals_gt(columns = d, value = 100) |> -#' col_vals_lte(columns = c, value = 5) |> +#' col_vals_le(columns = c, value = 5) |> #' interrogate() #' ``` #' @@ -907,7 +907,7 @@ export_report <- function( #' col_exists(columns = c(date, date_time)) |> #' col_vals_regex( #' columns = b, -#' regex = "[0-9]-[a-z]{3}-[0-9]{3}" +#' pattern = "[0-9]-[a-z]{3}-[0-9]{3}" #' ) |> #' rows_distinct() |> #' interrogate() diff --git a/R/remove_deactivate.R b/R/remove_deactivate.R index f0001a788..d29a26e2c 100644 --- a/R/remove_deactivate.R +++ b/R/remove_deactivate.R @@ -65,7 +65,7 @@ #' ) |> #' col_vals_regex( #' columns = b, -#' regex = "[0-9]-[a-z]{3}-[0-9]{3}", +#' pattern = "[0-9]-[a-z]{3}-[0-9]{3}", #' active = FALSE #' ) |> #' interrogate() @@ -149,7 +149,7 @@ activate_steps <- function( #' col_exists(columns = date) |> #' col_vals_regex( #' columns = b, -#' regex = "[0-9]-[a-z]{3}-[0-9]" +#' pattern = "[0-9]-[a-z]{3}-[0-9]" #' ) |> #' interrogate() #' @@ -230,7 +230,7 @@ deactivate_steps <- function( #' col_exists(columns = date) |> #' col_vals_regex( #' columns = b, -#' regex = "[0-9]-[a-z]{3}-[0-9]" +#' pattern = "[0-9]-[a-z]{3}-[0-9]" #' ) |> #' interrogate() #' diff --git a/R/table_transformers.R b/R/table_transformers.R index ce567c1bc..8eb71de1f 100644 --- a/R/table_transformers.R +++ b/R/table_transformers.R @@ -250,12 +250,12 @@ tt_summary_stats <- function(tbl) { #' We see data, and not an error, so both validations were successful! #' #' Let's use a `tt_string_info()`-transformed table with the -#' [test_col_vals_lte()] to check that the maximum string length in column `f` +#' [test_col_vals_le()] to check that the maximum string length in column `f` #' of the `small_table` dataset is no greater than `4`. #' #' ```{r} #' tt_string_info(tbl = small_table) |> -#' test_col_vals_lte( +#' test_col_vals_le( #' columns = f, #' value = 4 #' ) @@ -922,7 +922,7 @@ tt_time_slice <- function( #' function. So if we wanted to test whether the maximum session duration during #' the rest of the time period (the remaining 0.75) is never higher than that of #' the first quarter of the year, we can supply a value from `stats_tbl` to -#' [test_col_vals_lte()]: +#' [test_col_vals_le()]: #' #' ```{r} #' game_revenue |> @@ -930,7 +930,7 @@ tt_time_slice <- function( #' slice_point = 0.25, #' keep = "right" #' ) |> -#' test_col_vals_lte( +#' test_col_vals_le( #' columns = session_duration, #' value = get_tt_param( #' tbl = stats_tbl, diff --git a/R/write_testthat_file.R b/R/write_testthat_file.R index 9ffd8d24d..fab567c86 100644 --- a/R/write_testthat_file.R +++ b/R/write_testthat_file.R @@ -86,7 +86,7 @@ #' #' test_that("values in `c` should be <= `5`", { #' -#' expect_col_vals_lte( +#' expect_col_vals_le( #' tbl, #' columns = c, #' value = 5, @@ -107,7 +107,7 @@ #' actions = action_levels(error = 0.25) #' ) |> #' col_exists(date_time) |> -#' col_vals_lte(c, value = 5) +#' col_vals_le(c, value = 5) #' #' write_testthat_file( #' agent = agent, @@ -209,10 +209,10 @@ #' col_exists(c(date, date_time)) |> #' col_vals_regex( #' b, -#' regex = "[0-9]-[a-z]{3}-[0-9]{3}" +#' pattern = "[0-9]-[a-z]{3}-[0-9]{3}" #' ) |> #' col_vals_gt(d, value = 100) |> -#' col_vals_lte(c, value = 5) |> +#' col_vals_le(c, value = 5) |> #' interrogate() #' ``` #' @@ -265,7 +265,7 @@ #' expect_col_vals_regex( #' tbl, #' columns = b, -#' regex = "[0-9]-[a-z]{3}-[0-9]{3}", +#' pattern = "[0-9]-[a-z]{3}-[0-9]{3}", #' threshold = 0.25 #' ) #' }) @@ -282,7 +282,7 @@ #' #' test_that("values in `c` should be <= `5`", { #' -#' expect_col_vals_lte( +#' expect_col_vals_le( #' tbl, #' columns = c, #' value = 5, diff --git a/R/yaml_read_agent.R b/R/yaml_read_agent.R index b30e8da1a..c00944d11 100644 --- a/R/yaml_read_agent.R +++ b/R/yaml_read_agent.R @@ -311,11 +311,11 @@ yaml_agent_interrogate <- function( #' col_exists(columns = c(date, date_time)) |> #' col_vals_regex( #' columns = b, -#' regex = "[0-9]-[a-z]{3}-[0-9]{3}" +#' pattern = "[0-9]-[a-z]{3}-[0-9]{3}" #' ) |> #' rows_distinct() |> #' col_vals_gt(columns = d, value = 100) |> -#' col_vals_lte(columns = c, value = 5) +#' col_vals_le(columns = c, value = 5) #' ``` #' #' The agent can be written to a **pointblank** YAML file with [yaml_write()]. @@ -365,14 +365,14 @@ yaml_agent_interrogate <- function( #' ) |> #' col_vals_regex( #' columns = b, -#' regex = "[0-9]-[a-z]{3}-[0-9]{3}" +#' pattern = "[0-9]-[a-z]{3}-[0-9]{3}" #' ) |> #' rows_distinct() |> #' col_vals_gt( #' columns = d, #' value = 100 #' ) |> -#' col_vals_lte( +#' col_vals_le( #' columns = c, #' value = 5 #' ) diff --git a/R/yaml_write.R b/R/yaml_write.R index 82edb52c6..e8a43dde6 100644 --- a/R/yaml_write.R +++ b/R/yaml_write.R @@ -142,11 +142,11 @@ #' col_exists(columns = c(date, date_time)) |> #' col_vals_regex( #' columns = b, -#' regex = "[0-9]-[a-z]{3}-[0-9]{3}" +#' pattern = "[0-9]-[a-z]{3}-[0-9]{3}" #' ) |> #' rows_distinct() |> #' col_vals_gt(columns = d, value = 100) |> -#' col_vals_lte(columns = c, value = 5) +#' col_vals_le(columns = c, value = 5) #' ``` #' #' The agent can be written to a **pointblank**-readable YAML file with the @@ -187,7 +187,7 @@ #' - col_vals_gt: #' columns: c(d) #' value: 100.0 -#' - col_vals_lte: +#' - col_vals_le: #' columns: c(c) #' value: 5.0 #' ``` @@ -627,7 +627,7 @@ yaml_write <- function( #' - col_vals_gt: #' columns: vars(d) #' value: 100.0 -#' - col_vals_lte: +#' - col_vals_le: #' columns: vars(c) #' value: 5.0 #' ``` @@ -1242,7 +1242,7 @@ as_agent_yaml_list <- function(agent, expanded) { list( validation_fn = list( columns = column_text, - regex = get_arg_value(step_list$values), + pattern = get_arg_value(step_list$values), na_pass = step_list$na_pass, preconditions = as_list_preconditions(step_list$preconditions), segments = as_list_segments(step_list$seg_expr), diff --git a/inst/img/function_icons/col_vals_ge.png b/inst/img/function_icons/col_vals_ge.png new file mode 100644 index 000000000..2b981f059 Binary files /dev/null and b/inst/img/function_icons/col_vals_ge.png differ diff --git a/inst/img/function_icons/col_vals_ge.svg b/inst/img/function_icons/col_vals_ge.svg new file mode 100644 index 000000000..6c99ccfb5 --- /dev/null +++ b/inst/img/function_icons/col_vals_ge.svg @@ -0,0 +1,10 @@ + + + col_vals_gte + + + + + + + \ No newline at end of file diff --git a/inst/img/function_icons/col_vals_le.png b/inst/img/function_icons/col_vals_le.png new file mode 100644 index 000000000..c1a3eb8ce Binary files /dev/null and b/inst/img/function_icons/col_vals_le.png differ diff --git a/inst/img/function_icons/col_vals_le.svg b/inst/img/function_icons/col_vals_le.svg new file mode 100644 index 000000000..c25ac1364 --- /dev/null +++ b/inst/img/function_icons/col_vals_le.svg @@ -0,0 +1,10 @@ + + + col_vals_lte + + + + + + + \ No newline at end of file diff --git a/inst/yaml/agent-small_table.yml b/inst/yaml/agent-small_table.yml index 78dc055f5..90abf5670 100644 --- a/inst/yaml/agent-small_table.yml +++ b/inst/yaml/agent-small_table.yml @@ -15,12 +15,12 @@ steps: columns: vars(date_time) - col_vals_regex: columns: vars(b) - regex: '[0-9]-[a-z]{3}-[0-9]{3}' + pattern: '[0-9]-[a-z]{3}-[0-9]{3}' - rows_distinct: columns: ~ - col_vals_gt: columns: vars(d) value: 100.0 -- col_vals_lte: +- col_vals_le: columns: vars(c) value: 5.0 diff --git a/man/activate_steps.Rd b/man/activate_steps.Rd index 27794e648..9ef8d9e6c 100644 --- a/man/activate_steps.Rd +++ b/man/activate_steps.Rd @@ -56,7 +56,7 @@ agent_1 <- ) |> col_vals_regex( columns = b, - regex = "[0-9]-[a-z]{3}-[0-9]{3}", + pattern = "[0-9]-[a-z]{3}-[0-9]{3}", active = FALSE ) |> interrogate() diff --git a/man/all_passed.Rd b/man/all_passed.Rd index b5fea19ab..d19fa7131 100644 --- a/man/all_passed.Rd +++ b/man/all_passed.Rd @@ -69,7 +69,7 @@ Validate that values in column \code{a} are always greater than 4. \if{html}{\out{
}}\preformatted{agent <- create_agent(tbl = tbl) |> col_vals_gt(columns = a, value = 3) |> - col_vals_lte(columns = a, value = 10) |> + col_vals_le(columns = a, value = 10) |> col_vals_increasing(columns = a) |> interrogate() }\if{html}{\out{
}} diff --git a/man/col_vals_between.Rd b/man/col_vals_between.Rd index 8d4701636..1bda6c7dd 100644 --- a/man/col_vals_between.Rd +++ b/man/col_vals_between.Rd @@ -213,7 +213,7 @@ specified as single, literal values or as column names given in \code{vars()}. T and \code{right}, states whether each bound is inclusive or not. The default is \code{c(TRUE, TRUE)}, where both endpoints are inclusive (i.e., \verb{[left, right]}). For partially-unbounded versions of this function, we can use the -\code{\link[=col_vals_lt]{col_vals_lt()}}, \code{\link[=col_vals_lte]{col_vals_lte()}}, \code{\link[=col_vals_gt]{col_vals_gt()}}, or \code{\link[=col_vals_gte]{col_vals_gte()}} +\code{\link[=col_vals_lt]{col_vals_lt()}}, \code{\link[=col_vals_le]{col_vals_le()}}, \code{\link[=col_vals_gt]{col_vals_gt()}}, or \code{\link[=col_vals_ge]{col_vals_ge()}} validation functions. The validation function can be used directly on a data table or with an \emph{agent} object (technically, a \code{ptblank_agent} object) whereas the expectation and test functions can only be used with a data diff --git a/man/col_vals_not_between.Rd b/man/col_vals_not_between.Rd index 6526f324e..88047dba1 100644 --- a/man/col_vals_not_between.Rd +++ b/man/col_vals_not_between.Rd @@ -213,7 +213,7 @@ literal values or as column names given in \code{vars()}. The \code{inclusive} argument, as a vector of two logical values relating to \code{left} and \code{right}, states whether each bound is inclusive or not. The default is \code{c(TRUE, TRUE)}, where both endpoints are inclusive (i.e., \verb{[left, right]}). For partially-unbounded versions of this function, we can use the -\code{\link[=col_vals_lt]{col_vals_lt()}}, \code{\link[=col_vals_lte]{col_vals_lte()}}, \code{\link[=col_vals_gt]{col_vals_gt()}}, or \code{\link[=col_vals_gte]{col_vals_gte()}} +\code{\link[=col_vals_lt]{col_vals_lt()}}, \code{\link[=col_vals_le]{col_vals_le()}}, \code{\link[=col_vals_gt]{col_vals_gt()}}, or \code{\link[=col_vals_ge]{col_vals_ge()}} validation functions. The validation function can be used directly on a data table or with an \emph{agent} object (technically, a \code{ptblank_agent} object) whereas the expectation and test functions can only be used with a data diff --git a/man/col_vals_regex.Rd b/man/col_vals_regex.Rd index 0e79d62fd..2ab31874b 100644 --- a/man/col_vals_regex.Rd +++ b/man/col_vals_regex.Rd @@ -9,7 +9,7 @@ col_vals_regex( x, columns, - regex, + pattern, na_pass = FALSE, preconditions = NULL, segments = NULL, @@ -17,25 +17,28 @@ col_vals_regex( step_id = NULL, label = NULL, brief = NULL, - active = TRUE + active = TRUE, + regex = NULL ) expect_col_vals_regex( object, columns, - regex, + pattern, na_pass = FALSE, preconditions = NULL, - threshold = 1 + threshold = 1, + regex = NULL ) test_col_vals_regex( object, columns, - regex, + pattern, na_pass = FALSE, preconditions = NULL, - threshold = 1 + threshold = 1, + regex = NULL ) } \arguments{ @@ -55,7 +58,7 @@ A column-selecting expression, as one would use inside \code{dplyr::select()}. Specifies the column (or a set of columns) to which this validation should be applied. See the \emph{Column Names} section for more information.} -\item{regex}{\emph{Regex pattern} +\item{pattern}{\emph{Regex pattern} \verb{scalar} // \strong{required} @@ -148,6 +151,13 @@ logical value. With this approach, the \strong{pointblank} function active on the basis of one or more columns existing in the table (e.g., \verb{\\(x) x |> has_columns(c(d, e))}).} +\item{regex}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} + +\verb{scalar} // \strong{deprecated} + +Deprecated in favor of \code{pattern}. Providing a value here will work but +will emit a warning asking you to switch to \code{pattern}.} + \item{object}{\emph{A data table for expectations or tests} \verb{obj:} // \strong{required} @@ -181,9 +191,9 @@ The test function returns a logical value. \description{ The \code{col_vals_regex()} validation function, the \code{expect_col_vals_regex()} expectation function, and the \code{test_col_vals_regex()} test function all check -whether column values in a table correspond to a \code{regex} matching expression. -The validation function can be used directly on a data table or with an -\emph{agent} object (technically, a \code{ptblank_agent} object) whereas the +whether column values in a table correspond to a \code{pattern} matching +expression. The validation function can be used directly on a data table or +with an \emph{agent} object (technically, a \code{ptblank_agent} object) whereas the expectation and test functions can only be used with a data table. Each validation step or expectation will operate over the number of test units that is equal to the number of rows in the table (after any \code{preconditions} @@ -347,10 +357,10 @@ representation. R statement: -\if{html}{\out{
}}\preformatted{agent |> +\if{html}{\out{
}}\preformatted{agent |> col_vals_regex( columns = a, - regex = "[0-9]-[a-z]\{3\}-[0-9]\{3\}", + pattern = "[0-9]-[a-z]\{3\}-[0-9]\{3\}", na_pass = TRUE, preconditions = \\(x) x |> dplyr::filter(a < 10), segments = b ~ c("group_1", "group_2"), @@ -365,7 +375,7 @@ YAML representation: \if{html}{\out{
}}\preformatted{steps: - col_vals_regex: columns: c(a) - regex: '[0-9]-[a-z]\{3\}-[0-9]\{3\}' + pattern: '[0-9]-[a-z]\{3\}-[0-9]\{3\}' na_pass: true preconditions: ~. \%>\% dplyr::filter(a < 10) segments: b ~ c("group_1", "group_2") @@ -377,11 +387,14 @@ YAML representation: }\if{html}{\out{
}} In practice, both of these will often be shorter as only the \code{columns} and -\code{regex} arguments require values. Arguments with default values won't be +\code{pattern} arguments require values. Arguments with default values won't be written to YAML when using \code{\link[=yaml_write]{yaml_write()}} (though it is acceptable to include them with their default when generating the YAML by other means). It is also possible to preview the transformation of an agent to YAML without any writing to disk by using the \code{\link[=yaml_agent_string]{yaml_agent_string()}} function. + +Note that YAML files previously written with a \verb{regex:} key are still +accepted — the value will be used as the \code{pattern}. } \section{Examples}{ @@ -422,7 +435,7 @@ units, one for each row). \if{html}{\out{
}}\preformatted{agent <- create_agent(tbl = small_table) |> - col_vals_regex(columns = b, regex = pattern) |> + col_vals_regex(columns = b, pattern = pattern) |> interrogate() }\if{html}{\out{
}} @@ -444,7 +457,7 @@ through but should \code{stop()} if there is a single test unit failing. The behavior of side effects can be customized with the \code{actions} option. \if{html}{\out{
}}\preformatted{small_table |> - col_vals_regex(columns = b, regex = pattern) |> + col_vals_regex(columns = b, pattern = pattern) |> dplyr::slice(1:5) #> # A tibble: 5 x 8 #> date_time date a b c d e f @@ -462,7 +475,7 @@ behavior of side effects can be customized with the \code{actions} option. With the \verb{expect_*()} form, we would typically perform one validation at a time. This is primarily used in \strong{testthat} tests. -\if{html}{\out{
}}\preformatted{expect_col_vals_regex(small_table, columns = b, regex = pattern) +\if{html}{\out{
}}\preformatted{expect_col_vals_regex(small_table, columns = b, pattern = pattern) }\if{html}{\out{
}} } @@ -471,7 +484,7 @@ time. This is primarily used in \strong{testthat} tests. With the \verb{test_*()} form, we should get a single logical value returned to us. -\if{html}{\out{
}}\preformatted{small_table |> test_col_vals_regex(columns = b, regex = pattern) +\if{html}{\out{
}}\preformatted{small_table |> test_col_vals_regex(columns = b, pattern = pattern) #> [1] TRUE }\if{html}{\out{
}} } diff --git a/man/conjointly.Rd b/man/conjointly.Rd index 1d9204007..0c4629346 100644 --- a/man/conjointly.Rd +++ b/man/conjointly.Rd @@ -51,7 +51,7 @@ commonly created with \code{\link[=create_agent]{create_agent()}}.} A collection one-sided formulas that consist of validation functions that validate row units (the \verb{col_vals_*()} series), column existence (\code{\link[=col_exists]{col_exists()}}), or column type (the \verb{col_is_*()} series). An example of -this is \verb{~ col_vals_gte(., a, 5.5), ~ col_vals_not_null(., b}).} +this is \verb{~ col_vals_ge(., a, 5.5), ~ col_vals_not_null(., b}).} \item{.list}{\emph{Alternative to \code{...}} diff --git a/man/create_agent.Rd b/man/create_agent.Rd index e34b95465..4a8dbd54a 100644 --- a/man/create_agent.Rd +++ b/man/create_agent.Rd @@ -419,7 +419,7 @@ to actually perform the validations and gather intel. ) |> rows_distinct() |> col_vals_gt(columns = d, value = 100) |> - col_vals_lte(columns = c, value = 5) |> + col_vals_le(columns = c, value = 5) |> col_vals_between( columns = c, left = vars(a), right = vars(d), diff --git a/man/deactivate_steps.Rd b/man/deactivate_steps.Rd index ed72f35ea..6739cbb6d 100644 --- a/man/deactivate_steps.Rd +++ b/man/deactivate_steps.Rd @@ -54,7 +54,7 @@ agent_1 <- col_exists(columns = date) |> col_vals_regex( columns = b, - regex = "[0-9]-[a-z]{3}-[0-9]" + pattern = "[0-9]-[a-z]{3}-[0-9]" ) |> interrogate() diff --git a/man/export_report.Rd b/man/export_report.Rd index 06f0fc1d5..7b2d0c550 100644 --- a/man/export_report.Rd +++ b/man/export_report.Rd @@ -91,11 +91,11 @@ many validation functions as we want. Then, we \code{\link[=interrogate]{interro col_exists(columns = c(date, date_time)) |> col_vals_regex( columns = b, - regex = "[0-9]-[a-z]\{3\}-[0-9]\{3\}" + pattern = "[0-9]-[a-z]\{3\}-[0-9]\{3\}" ) |> rows_distinct() |> col_vals_gt(columns = d, value = 100) |> - col_vals_lte(columns = c, value = 5) |> + col_vals_le(columns = c, value = 5) |> interrogate() }\if{html}{\out{
}} diff --git a/man/get_tt_param.Rd b/man/get_tt_param.Rd index 25bbb9c50..8d953d5af 100644 --- a/man/get_tt_param.Rd +++ b/man/get_tt_param.Rd @@ -86,14 +86,14 @@ Sometimes you need a single value from the table generated by the function. So if we wanted to test whether the maximum session duration during the rest of the time period (the remaining 0.75) is never higher than that of the first quarter of the year, we can supply a value from \code{stats_tbl} to -\code{\link[=test_col_vals_lte]{test_col_vals_lte()}}: +\code{\link[=test_col_vals_le]{test_col_vals_le()}}: \if{html}{\out{
}}\preformatted{game_revenue |> tt_time_slice( slice_point = 0.25, keep = "right" ) |> - test_col_vals_lte( + test_col_vals_le( columns = session_duration, value = get_tt_param( tbl = stats_tbl, diff --git a/man/remove_steps.Rd b/man/remove_steps.Rd index 7b23b3b90..85c028d4e 100644 --- a/man/remove_steps.Rd +++ b/man/remove_steps.Rd @@ -54,7 +54,7 @@ agent_1 <- col_exists(columns = date) |> col_vals_regex( columns = b, - regex = "[0-9]-[a-z]{3}-[0-9]" + pattern = "[0-9]-[a-z]{3}-[0-9]" ) |> interrogate() diff --git a/man/set_tbl.Rd b/man/set_tbl.Rd index 4788dba66..014182b4b 100644 --- a/man/set_tbl.Rd +++ b/man/set_tbl.Rd @@ -74,7 +74,7 @@ Apply the actions, add some validation steps and then interrogate the data. col_exists(columns = c(date, date_time)) |> col_vals_regex( columns = b, - regex = "[0-9]-[a-z]\{3\}-[0-9]\{3\}" + pattern = "[0-9]-[a-z]\{3\}-[0-9]\{3\}" ) |> rows_distinct() |> interrogate() diff --git a/man/tt_string_info.Rd b/man/tt_string_info.Rd index b070b40fe..e09c178a0 100644 --- a/man/tt_string_info.Rd +++ b/man/tt_string_info.Rd @@ -70,17 +70,14 @@ numbers of characters (\code{15} and \code{24}, respectively) throughout the tab We see data, and not an error, so both validations were successful! Let's use a \code{tt_string_info()}-transformed table with the -\code{\link[=test_col_vals_lte]{test_col_vals_lte()}} to check that the maximum string length in column \code{f} +\code{\link[=test_col_vals_le]{test_col_vals_le()}} to check that the maximum string length in column \code{f} of the \code{small_table} dataset is no greater than \code{4}. \if{html}{\out{
}}\preformatted{tt_string_info(tbl = small_table) |> - test_col_vals_lte( + test_col_vals_le( columns = f, value = 4 ) -#> Warning: `test_col_vals_lte()` is deprecated. -#> i Please use `test_col_vals_le()` instead. -#> This warning is displayed once per session. #> [1] TRUE }\if{html}{\out{
}} } diff --git a/man/write_testthat_file.Rd b/man/write_testthat_file.Rd index a7edf8d01..b8c791e80 100644 --- a/man/write_testthat_file.Rd +++ b/man/write_testthat_file.Rd @@ -131,7 +131,7 @@ test_that("column `date_time` exists", \{ test_that("values in `c` should be <= `5`", \{ - expect_col_vals_lte( + expect_col_vals_le( tbl, columns = c, value = 5, @@ -151,7 +151,7 @@ agent <- actions = action_levels(error = 0.25) ) |> col_exists(date_time) |> - col_vals_lte(c, value = 5) + col_vals_le(c, value = 5) write_testthat_file( agent = agent, @@ -212,10 +212,10 @@ bit more useful after interrogation. col_exists(c(date, date_time)) |> col_vals_regex( b, - regex = "[0-9]-[a-z]\{3\}-[0-9]\{3\}" + pattern = "[0-9]-[a-z]\{3\}-[0-9]\{3\}" ) |> col_vals_gt(d, value = 100) |> - col_vals_lte(c, value = 5) |> + col_vals_le(c, value = 5) |> interrogate() }\if{html}{\out{
}} @@ -266,7 +266,7 @@ test_that("values in `b` should match the regular expression: expect_col_vals_regex( tbl, columns = b, - regex = "[0-9]-[a-z]\{3\}-[0-9]\{3\}", + pattern = "[0-9]-[a-z]\{3\}-[0-9]\{3\}", threshold = 0.25 ) \}) @@ -283,7 +283,7 @@ test_that("values in `d` should be > `100`", \{ test_that("values in `c` should be <= `5`", \{ - expect_col_vals_lte( + expect_col_vals_le( tbl, columns = c, value = 5, diff --git a/man/x_write_disk.Rd b/man/x_write_disk.Rd index 8d0b99746..2d58238dd 100644 --- a/man/x_write_disk.Rd +++ b/man/x_write_disk.Rd @@ -125,11 +125,11 @@ using as many validation functions as we want. After that, use col_exists(columns = c(date, date_time)) |> col_vals_regex( columns = b, - regex = "[0-9]-[a-z]\{3\}-[0-9]\{3\}" + pattern = "[0-9]-[a-z]\{3\}-[0-9]\{3\}" ) |> rows_distinct() |> col_vals_gt(columns = d, value = 100) |> - col_vals_lte(columns = c, value = 5) |> + col_vals_le(columns = c, value = 5) |> interrogate() }\if{html}{\out{
}} diff --git a/man/yaml_agent_show_exprs.Rd b/man/yaml_agent_show_exprs.Rd index 1573d66ba..d641b6ea3 100644 --- a/man/yaml_agent_show_exprs.Rd +++ b/man/yaml_agent_show_exprs.Rd @@ -49,11 +49,11 @@ retrieval of the target table. col_exists(columns = c(date, date_time)) |> col_vals_regex( columns = b, - regex = "[0-9]-[a-z]\{3\}-[0-9]\{3\}" + pattern = "[0-9]-[a-z]\{3\}-[0-9]\{3\}" ) |> rows_distinct() |> col_vals_gt(columns = d, value = 100) |> - col_vals_lte(columns = c, value = 5) + col_vals_le(columns = c, value = 5) }\if{html}{\out{
}} The agent can be written to a \strong{pointblank} YAML file with \code{\link[=yaml_write]{yaml_write()}}. @@ -99,14 +99,14 @@ we can use \code{yaml_agent_show_exprs()}. ) |> col_vals_regex( columns = b, - regex = "[0-9]-[a-z]\{3\}-[0-9]\{3\}" + pattern = "[0-9]-[a-z]\{3\}-[0-9]\{3\}" ) |> rows_distinct() |> col_vals_gt( columns = d, value = 100 ) |> - col_vals_lte( + col_vals_le( columns = c, value = 5 ) diff --git a/man/yaml_agent_string.Rd b/man/yaml_agent_string.Rd index de26c4c57..3a8d4aa51 100644 --- a/man/yaml_agent_string.Rd +++ b/man/yaml_agent_string.Rd @@ -78,7 +78,7 @@ steps: - col_vals_gt: columns: vars(d) value: 100.0 -- col_vals_lte: +- col_vals_le: columns: vars(c) value: 5.0 }\if{html}{\out{
}} diff --git a/man/yaml_write.Rd b/man/yaml_write.Rd index c583d2ca9..7ed43895b 100644 --- a/man/yaml_write.Rd +++ b/man/yaml_write.Rd @@ -147,11 +147,11 @@ using as many validation functions as we want. col_exists(columns = c(date, date_time)) |> col_vals_regex( columns = b, - regex = "[0-9]-[a-z]\{3\}-[0-9]\{3\}" + pattern = "[0-9]-[a-z]\{3\}-[0-9]\{3\}" ) |> rows_distinct() |> col_vals_gt(columns = d, value = 100) |> - col_vals_lte(columns = c, value = 5) + col_vals_le(columns = c, value = 5) }\if{html}{\out{
}} The agent can be written to a \strong{pointblank}-readable YAML file with the @@ -189,7 +189,7 @@ steps: - col_vals_gt: columns: c(d) value: 100.0 -- col_vals_lte: +- col_vals_le: columns: c(c) value: 5.0 }\if{html}{\out{}} diff --git a/tests/testthat/_snaps/interrogate_with_agent.md b/tests/testthat/_snaps/interrogate_with_agent.md index 04932a790..b2990ce76 100644 --- a/tests/testthat/_snaps/interrogate_with_agent.md +++ b/tests/testthat/_snaps/interrogate_with_agent.md @@ -8,16 +8,16 @@ e), actions = al) %>% col_vals_between(columns = vars(d), left = 0, right = 5000, actions = al) %>% col_vals_equal(columns = vars(d), value = 283.94, actions = al) %>% col_vals_gt(columns = vars(date_time), value = vars(date), actions = al) %>% - col_vals_gte(columns = vars(date_time), value = vars(date), actions = al) %>% + col_vals_ge(columns = vars(date_time), value = vars(date), actions = al) %>% col_vals_lt(columns = vars(date_time), value = vars(date), actions = al) %>% - col_vals_lte(columns = vars(date_time), value = vars(date), actions = al) %>% + col_vals_le(columns = vars(date_time), value = vars(date), actions = al) %>% col_vals_in_set(columns = vars(f), set = c("low", "mid", "high"), actions = al) %>% col_vals_not_between(columns = vars(d), left = 500, right = 1000, actions = al) %>% col_vals_not_equal(columns = vars(d), value = 283.94, actions = al) %>% col_vals_not_in_set(columns = vars(f), set = c("lower", "middle", "higher"), actions = al) %>% col_vals_not_null(columns = vars(c), actions = al) %>% col_vals_null(columns = vars(b), actions = al) %>% col_vals_regex(columns = vars( - f), regex = "[a-z]{3}", actions = al) %>% rows_distinct(actions = al) %>% + f), pattern = "[a-z]{3}", actions = al) %>% rows_distinct(actions = al) %>% conjointly(~ col_vals_gt(., columns = vars(a), value = 1), ~ col_vals_lt(., columns = vars(c), value = 10, na_pass = TRUE), ~ col_vals_not_null(., columns = vars(d)), actions = al) %>% serially(~ test_col_vals_gt(., diff --git a/tests/testthat/postgres.R b/tests/testthat/postgres.R index f83724430..a20c2eec1 100644 --- a/tests/testthat/postgres.R +++ b/tests/testthat/postgres.R @@ -29,8 +29,8 @@ test_that("pointblank agent works with dittodb-mocked Postgres database connecti label = "trade_statistics: 'hs07_yrp' table", actions = al ) %>% - col_vals_gte(vars(export_value_usd), 0) %>% - col_vals_gte(vars(import_value_usd), 0) %>% + col_vals_ge(vars(export_value_usd), 0) %>% + col_vals_ge(vars(import_value_usd), 0) %>% col_schema_match( schema = col_schema( year = "integer", diff --git a/tests/testthat/test-brief.R b/tests/testthat/test-brief.R index 8e678a2e0..e75c2c49a 100644 --- a/tests/testthat/test-brief.R +++ b/tests/testthat/test-brief.R @@ -110,10 +110,10 @@ test_that("Briefs batch tests", { # columns + segments test_multi_briefs("col_vals_lt", value = 5) - test_multi_briefs("col_vals_lte", value = 5) + test_multi_briefs("col_vals_le", value = 5) test_multi_briefs("col_vals_equal", value = 5) test_multi_briefs("col_vals_not_equal", value = 5) - test_multi_briefs("col_vals_gte", value = 5) + test_multi_briefs("col_vals_ge", value = 5) test_multi_briefs("col_vals_gt", value = 5) test_multi_briefs("col_vals_between", left = 2, right = 5) test_multi_briefs("col_vals_not_between", left = 2, right = 5) @@ -125,7 +125,7 @@ test_that("Briefs batch tests", { test_multi_briefs("col_vals_not_null") test_multi_briefs("col_vals_increasing") test_multi_briefs("col_vals_decreasing") - test_multi_briefs("col_vals_regex", regex = "abc") + test_multi_briefs("col_vals_regex", pattern = "abc") test_multi_briefs("col_vals_within_spec", spec = "email") # segments diff --git a/tests/testthat/test-create_multiagent.R b/tests/testthat/test-create_multiagent.R index ae215a209..2080a2f7d 100644 --- a/tests/testthat/test-create_multiagent.R +++ b/tests/testthat/test-create_multiagent.R @@ -41,7 +41,7 @@ test_that("Creating a valid `multiagent` object is possible", { ) %>% rows_distinct() %>% col_vals_gt(vars(d), 100) %>% - col_vals_lte(vars(c), 5) %>% + col_vals_le(vars(c), 5) %>% col_vals_equal( vars(d), vars(d), na_pass = TRUE diff --git a/tests/testthat/test-create_validation_steps.R b/tests/testthat/test-create_validation_steps.R index 7b035ec87..d740d38b1 100644 --- a/tests/testthat/test-create_validation_steps.R +++ b/tests/testthat/test-create_validation_steps.R @@ -526,13 +526,13 @@ test_that("Creating a `col_vals_gt()` step is possible", { c("date_time", "date", "a", "b", "c", "d", "e", "f")) }) -test_that("Creating a `col_vals_gte()` step is possible", { +test_that("Creating a `col_vals_ge()` step is possible", { - # Use `col_vals_gte()` function to create + # Use `col_vals_ge()` function to create # a validation step validation <- create_agent(tbl = small_table) %>% - col_vals_gte(columns = vars(b), value = 5) + col_vals_ge(columns = vars(b), value = 5) # Expect the class name for the object # to be `ptblank_agent` @@ -559,7 +559,7 @@ test_that("Creating a `col_vals_gte()` step is possible", { # `everything()` helper function validation_all <- create_agent(tbl = small_table) %>% - col_vals_gte(columns = everything(), value = 5) + col_vals_ge(columns = everything(), value = 5) # Expect 8 rows in the `validation_all$validation_set` object expect_equal(nrow(validation_all$validation_set), 8) @@ -614,13 +614,13 @@ test_that("Creating a `col_vals_lt()` step is possible", { c("date_time", "date", "a", "b", "c", "d", "e", "f")) }) -test_that("Creating a `col_vals_lte()` step is possible", { +test_that("Creating a `col_vals_le()` step is possible", { - # Use `col_vals_lte()` function to create + # Use `col_vals_le()` function to create # a validation step validation <- create_agent(tbl = small_table) %>% - col_vals_lte(columns = vars(b), value = 5) + col_vals_le(columns = vars(b), value = 5) # Expect the class name for the object # to be `ptblank_agent` @@ -647,7 +647,7 @@ test_that("Creating a `col_vals_lte()` step is possible", { # `everything()` helper function validation_all <- create_agent(tbl = small_table) %>% - col_vals_lte(columns = everything(), value = 5) + col_vals_le(columns = everything(), value = 5) # Expect 8 rows in the `validation_all$validation_set` object expect_equal(nrow(validation_all$validation_set), 8) @@ -840,7 +840,7 @@ test_that("Creating a `col_vals_regex()` step is possible", { # a validation step validation <- create_agent(tbl = small_table) %>% - col_vals_regex(columns = vars(b), regex = "[0-9]-.*") + col_vals_regex(columns = vars(b), pattern = "[0-9]-.*") # Expect the class name for the object # to be `ptblank_agent` @@ -867,7 +867,7 @@ test_that("Creating a `col_vals_regex()` step is possible", { # `everything()` helper function validation_all <- create_agent(tbl = small_table) %>% - col_vals_regex(columns = everything(), regex = "[0-9]-.*") + col_vals_regex(columns = everything(), pattern = "[0-9]-.*") # Expect 8 rows in the `validation_all$validation_set` object expect_equal(nrow(validation_all$validation_set), 8) diff --git a/tests/testthat/test-expectation_fns.R b/tests/testthat/test-expectation_fns.R index 4d278be25..326b591dd 100644 --- a/tests/testthat/test-expectation_fns.R +++ b/tests/testthat/test-expectation_fns.R @@ -124,28 +124,28 @@ test_that("pointblank expectation function produce the correct results", { ) # - # expect_col_vals_lte() + # expect_col_vals_le() # - expect_col_vals_lte(tbl, columns = vars(a), value = 8) - expect_success(expect_col_vals_lte(tbl, columns = vars(a), value = 8)) + expect_col_vals_le(tbl, columns = vars(a), value = 8) + expect_success(expect_col_vals_le(tbl, columns = vars(a), value = 8)) - expect_failure(expect_col_vals_lte(tbl, columns = vars(a), value = 7)) - expect_success(expect_col_vals_lte(tbl, columns = vars(a), value = 7, threshold = 2)) - expect_success(expect_col_vals_lte(tbl, columns = vars(a), value = 0, threshold = 1000)) + expect_failure(expect_col_vals_le(tbl, columns = vars(a), value = 7)) + expect_success(expect_col_vals_le(tbl, columns = vars(a), value = 7, threshold = 2)) + expect_success(expect_col_vals_le(tbl, columns = vars(a), value = 0, threshold = 1000)) - expect_error(expect_col_vals_lte(tbl, columns = vars(a), value = 7), class = "expectation_failure") + expect_error(expect_col_vals_le(tbl, columns = vars(a), value = 7), class = "expectation_failure") - expect_failure(expect_col_vals_lte(tbl, columns = vars(a), value = 7, threshold = 1), failed_beyond_absolute) - expect_failure(expect_col_vals_lte(tbl, columns = vars(a), value = 7, threshold = 0.01), failed_beyond_proportional) + expect_failure(expect_col_vals_le(tbl, columns = vars(a), value = 7, threshold = 1), failed_beyond_absolute) + expect_failure(expect_col_vals_le(tbl, columns = vars(a), value = 7, threshold = 0.01), failed_beyond_proportional) expect_failure( - expect_col_vals_lte(tbl, columns = vars(a), value = 7), + expect_col_vals_le(tbl, columns = vars(a), value = 7), "failure level \\(1\\) >= failure threshold \\(1\\)" ) eval_batch_expect_fns( - expect_fn = expect_col_vals_lte, + expect_fn = expect_col_vals_le, tbl_test = tibble::tibble( x = c(5, 6, 10.5), # failing @@ -220,30 +220,30 @@ test_that("pointblank expectation function produce the correct results", { ) # - # expect_col_vals_gte() + # expect_col_vals_ge() # - expect_col_vals_gte(tbl, columns = vars(a), value = 0) - expect_col_vals_gte(tbl, columns = vars(c), value = 0, na_pass = TRUE) - expect_success(expect_col_vals_gte(tbl, columns = vars(c), value = 0, na_pass = TRUE)) + expect_col_vals_ge(tbl, columns = vars(a), value = 0) + expect_col_vals_ge(tbl, columns = vars(c), value = 0, na_pass = TRUE) + expect_success(expect_col_vals_ge(tbl, columns = vars(c), value = 0, na_pass = TRUE)) - expect_failure(expect_col_vals_gte(tbl, columns = vars(c), value = 0)) - expect_failure(expect_col_vals_gte(tbl, columns = vars(c), value = NA)) - expect_success(expect_col_vals_gte(tbl, columns = vars(c), value = 8, na_pass = TRUE, threshold = 0.6)) - expect_success(expect_col_vals_gte(tbl, columns = vars(c), value = 0, threshold = 1000)) + expect_failure(expect_col_vals_ge(tbl, columns = vars(c), value = 0)) + expect_failure(expect_col_vals_ge(tbl, columns = vars(c), value = NA)) + expect_success(expect_col_vals_ge(tbl, columns = vars(c), value = 8, na_pass = TRUE, threshold = 0.6)) + expect_success(expect_col_vals_ge(tbl, columns = vars(c), value = 0, threshold = 1000)) - expect_error(expect_col_vals_gte(tbl, columns = vars(c), value = 0), class = "expectation_failure") + expect_error(expect_col_vals_ge(tbl, columns = vars(c), value = 0), class = "expectation_failure") - expect_failure(expect_col_vals_gte(tbl, columns = vars(c), value = 0, threshold = 1), failed_beyond_absolute) - expect_failure(expect_col_vals_gte(tbl, columns = vars(c), value = 0, threshold = 0.01), failed_beyond_proportional) + expect_failure(expect_col_vals_ge(tbl, columns = vars(c), value = 0, threshold = 1), failed_beyond_absolute) + expect_failure(expect_col_vals_ge(tbl, columns = vars(c), value = 0, threshold = 0.01), failed_beyond_proportional) expect_failure( - expect_col_vals_gte(tbl, columns = vars(c), value = 0), + expect_col_vals_ge(tbl, columns = vars(c), value = 0), "failure level \\(2\\) >= failure threshold \\(1\\)" ) eval_batch_expect_fns( - expect_fn = expect_col_vals_gte, + expect_fn = expect_col_vals_ge, tbl_test = tibble::tibble( x = c(4, 1.5, 8.3), # failing @@ -632,18 +632,18 @@ test_that("pointblank expectation function produce the correct results", { # expect_col_vals_regex() # - expect_col_vals_regex(tbl, vars(b), regex = "^[0-9]-[a-z]{3}-[0-9]{3}$") - expect_success(expect_col_vals_regex(tbl, vars(b), regex = "^[0-9]-[a-z]{3}-[0-9]{3}$")) - expect_failure(expect_col_vals_regex(tbl, vars(b), regex = "^[0-9]-[a-z]{4}-[0-9]{3}$")) - expect_success(expect_col_vals_regex(tbl, vars(b), regex = "^[0-9]-[a-z]{4}-[0-9]{3}$", threshold = 1000)) + expect_col_vals_regex(tbl, vars(b), pattern = "^[0-9]-[a-z]{3}-[0-9]{3}$") + expect_success(expect_col_vals_regex(tbl, vars(b), pattern = "^[0-9]-[a-z]{3}-[0-9]{3}$")) + expect_failure(expect_col_vals_regex(tbl, vars(b), pattern = "^[0-9]-[a-z]{4}-[0-9]{3}$")) + expect_success(expect_col_vals_regex(tbl, vars(b), pattern = "^[0-9]-[a-z]{4}-[0-9]{3}$", threshold = 1000)) - expect_error(expect_col_vals_regex(tbl, vars(b), regex = "^[0-9]-[a-z]{4}-[0-9]{3}$"), class = "expectation_failure") + expect_error(expect_col_vals_regex(tbl, vars(b), pattern = "^[0-9]-[a-z]{4}-[0-9]{3}$"), class = "expectation_failure") - expect_failure(expect_col_vals_regex(tbl, vars(b), regex = "^[0-9]-[a-z]{4}-[0-9]{3}$", threshold = 1), failed_beyond_absolute) - expect_failure(expect_col_vals_regex(tbl, vars(b), regex = "^[0-9]-[a-z]{4}-[0-9]{3}$", threshold = 0.01), failed_beyond_proportional) + expect_failure(expect_col_vals_regex(tbl, vars(b), pattern = "^[0-9]-[a-z]{4}-[0-9]{3}$", threshold = 1), failed_beyond_absolute) + expect_failure(expect_col_vals_regex(tbl, vars(b), pattern = "^[0-9]-[a-z]{4}-[0-9]{3}$", threshold = 0.01), failed_beyond_proportional) expect_failure( - expect_col_vals_regex(tbl, vars(b), regex = "^[0-9]-[a-z]{4}-[0-9]{3}$"), + expect_col_vals_regex(tbl, vars(b), pattern = "^[0-9]-[a-z]{4}-[0-9]{3}$"), "failure level \\(13\\) >= failure threshold \\(1\\)" ) @@ -655,7 +655,7 @@ test_that("pointblank expectation function produce the correct results", { y = c("sea", "eat", "tea"), # passing z = c("unchallangeable", "levelheadedness", "reauthorization") # passing ), - regex = "ea" + pattern = "ea" ) # @@ -1629,10 +1629,10 @@ test_that("expect errors to be expressed by pointblank under some conditions", { # Errors caught and expressed when a column doesn't exist expect_error(expect_col_vals_lt(tbl, columns = vars(z), value = 0), regexp = no_col_msg) - expect_error(expect_col_vals_lte(tbl, columns = vars(z), value = 0), regexp = no_col_msg) + expect_error(expect_col_vals_le(tbl, columns = vars(z), value = 0), regexp = no_col_msg) expect_error(expect_col_vals_equal(tbl, columns = vars(z), value = 3), regexp = no_col_msg) expect_error(expect_col_vals_not_equal(tbl, columns = vars(z), value = 3), regexp = no_col_msg) - expect_error(expect_col_vals_gte(tbl, columns = vars(z), value = 0), regexp = no_col_msg) + expect_error(expect_col_vals_ge(tbl, columns = vars(z), value = 0), regexp = no_col_msg) expect_error(expect_col_vals_gt(tbl, columns = vars(z), value = 0), regexp = no_col_msg) expect_error(expect_col_vals_between(tbl, columns = vars(z), left = 0, right = 10000), regexp = no_col_msg) expect_error(expect_col_vals_not_between(tbl, columns = vars(z), left = 0, right = 10000), regexp = no_col_msg) @@ -1640,7 +1640,7 @@ test_that("expect errors to be expressed by pointblank under some conditions", { expect_error(expect_col_vals_not_in_set(tbl, columns = vars(z), set = LETTERS), regexp = no_col_msg) expect_error(expect_col_vals_null(tbl, columns = vars(z)), regexp = no_col_msg) expect_error(expect_col_vals_not_null(tbl, columns = vars(z)), regexp = no_col_msg) - expect_error(expect_col_vals_regex(tbl, vars(z), regex = "^[0-9]-[a-z]{3}-[0-9]{3}$"), regexp = no_col_msg) + expect_error(expect_col_vals_regex(tbl, vars(z), pattern = "^[0-9]-[a-z]{3}-[0-9]{3}$"), regexp = no_col_msg) expect_error(expect_col_vals_within_spec(tbl, vars(z), spec = "isbn"), regexp = no_col_msg) expect_error(expect_col_is_character(tbl, columns = vars(z)), regexp = no_col_msg) expect_error(expect_col_is_numeric(tbl, columns = vars(z)), regexp = no_col_msg) diff --git a/tests/testthat/test-get_data_extracts.R b/tests/testthat/test-get_data_extracts.R index d90b5b095..df9bd7c84 100644 --- a/tests/testthat/test-get_data_extracts.R +++ b/tests/testthat/test-get_data_extracts.R @@ -39,7 +39,7 @@ test_that("Getting data extracts is possible", { # produce a data extract during `interrogate()` agent <- create_agent(tbl = small_table) %>% - col_vals_gte(columns = vars(a), value = 1) %>% + col_vals_ge(columns = vars(a), value = 1) %>% interrogate() # Get a summary of the interrogation diff --git a/tests/testthat/test-get_multiagent_report.R b/tests/testthat/test-get_multiagent_report.R index ae40e5ad4..d7bc26b9a 100644 --- a/tests/testthat/test-get_multiagent_report.R +++ b/tests/testthat/test-get_multiagent_report.R @@ -41,7 +41,7 @@ test_that("Getting a multiagent report is possible", { ) %>% rows_distinct() %>% col_vals_gt(vars(d), 100) %>% - col_vals_lte(vars(c), 5) %>% + col_vals_le(vars(c), 5) %>% col_vals_equal( vars(d), vars(d), na_pass = TRUE diff --git a/tests/testthat/test-interrogate_simple.R b/tests/testthat/test-interrogate_simple.R index e0d266cd5..43cca43f0 100644 --- a/tests/testthat/test-interrogate_simple.R +++ b/tests/testthat/test-interrogate_simple.R @@ -97,14 +97,14 @@ test_that("Interrogating simply returns the expected results", { expect_false(exists("tbl_result")) # - # col_vals_lte() + # col_vals_le() # - # Use the `col_vals_lte()` function to perform + # Use the `col_vals_le()` function to perform # a simple validation step tbl_result <- tbl %>% - col_vals_lte( + col_vals_le( columns = vars(a), value = 8, actions = warn_on_fail() @@ -117,7 +117,7 @@ test_that("Interrogating simply returns the expected results", { expect_warning( tbl_result <- tbl %>% - col_vals_lte( + col_vals_le( columns = vars(a), value = 7, actions = warn_on_fail() @@ -133,7 +133,7 @@ test_that("Interrogating simply returns the expected results", { expect_error( tbl_result <- tbl %>% - col_vals_lte( + col_vals_le( columns = vars(a), value = 7, actions = error_on_fail() @@ -241,14 +241,14 @@ test_that("Interrogating simply returns the expected results", { expect_false(exists("tbl_result")) # - # col_vals_gte() + # col_vals_ge() # - # Use the `col_vals_gte()` function to perform + # Use the `col_vals_ge()` function to perform # a simple validation step tbl_result <- tbl %>% - col_vals_gte( + col_vals_ge( columns = vars(a), value = 1, actions = warn_on_fail() @@ -261,7 +261,7 @@ test_that("Interrogating simply returns the expected results", { expect_warning( tbl_result <- tbl %>% - col_vals_gte( + col_vals_ge( columns = vars(a), value = 2, actions = warn_on_fail() @@ -277,7 +277,7 @@ test_that("Interrogating simply returns the expected results", { expect_error( tbl_result <- tbl %>% - col_vals_gte( + col_vals_ge( columns = vars(a), value = 3, actions = error_on_fail() @@ -892,7 +892,7 @@ test_that("Interrogating simply returns the expected results", { tbl %>% col_vals_regex( columns = vars(b), - regex = "[0-9]-[a-z]*?-[0-9]*?", + pattern = "[0-9]-[a-z]*?-[0-9]*?", actions = warn_on_fail() ) @@ -905,7 +905,7 @@ test_that("Interrogating simply returns the expected results", { tbl %>% col_vals_regex( columns = vars(b), - regex = "[0-7]-[a-z]*?-[0-9]*?", + pattern = "[0-7]-[a-z]*?-[0-9]*?", actions = warn_on_fail() ) ) @@ -921,7 +921,7 @@ test_that("Interrogating simply returns the expected results", { tbl %>% col_vals_regex( columns = vars(b), - regex = "[0-7]-[a-z]*?-[0-9]*?", + pattern = "[0-7]-[a-z]*?-[0-9]*?", actions = error_on_fail() ) ) @@ -934,7 +934,7 @@ test_that("Interrogating simply returns the expected results", { data.frame(x = c("ab", "ac")) %>% col_vals_regex( columns = "x", - regex = "a(?!d)" + pattern = "a(?!d)" ) ) @@ -1863,12 +1863,12 @@ test_that("Interrogating simply incorporates the `na_pass` option", { ) ) - # Use the `col_vals_gte()` function to perform + # Use the `col_vals_ge()` function to perform # simple validation steps with NAs, switching the # value of the `na_pass` option expect_warning( dplyr::tibble(a = c(1.0, 1.5, 2.5, NA)) %>% - col_vals_gte( + col_vals_ge( columns = vars(a), value = 1.0, na_pass = FALSE, @@ -1878,7 +1878,7 @@ test_that("Interrogating simply incorporates the `na_pass` option", { expect_no_warning( dplyr::tibble(a = c(1.0, 1.5, 2.5, NA)) %>% - col_vals_gte( + col_vals_ge( columns = vars(a), value = 1.0, na_pass = TRUE, @@ -1909,12 +1909,12 @@ test_that("Interrogating simply incorporates the `na_pass` option", { ) ) - # Use the `col_vals_lte()` function to perform + # Use the `col_vals_le()` function to perform # simple validation steps with NAs, switching the # value of the `na_pass` option expect_warning( dplyr::tibble(a = c(1.0, 1.5, 2.5, NA)) %>% - col_vals_lte( + col_vals_le( columns = vars(a), value = 2.5, na_pass = FALSE, @@ -1924,7 +1924,7 @@ test_that("Interrogating simply incorporates the `na_pass` option", { expect_no_warning( dplyr::tibble(a = c(1.0, 1.5, 2.5, NA)) %>% - col_vals_lte( + col_vals_le( columns = vars(a), value = 2.5, na_pass = TRUE, @@ -1985,7 +1985,7 @@ test_that("Interrogating simply incorporates the `na_pass` option", { dplyr::tibble(a = c("1-bcd-345", "3-ldm-038", NA)) %>% col_vals_regex( columns = vars(a), - regex = "[0-9]-[a-z]{3}-[0-9]{3}", + pattern = "[0-9]-[a-z]{3}-[0-9]{3}", na_pass = FALSE, actions = warn_on_fail() ) @@ -1995,7 +1995,7 @@ test_that("Interrogating simply incorporates the `na_pass` option", { dplyr::tibble(a = c("1-bcd-345", "3-ldm-038", NA)) %>% col_vals_regex( columns = vars(a), - regex = "[0-9]-[a-z]{3}-[0-9]{3}", + pattern = "[0-9]-[a-z]{3}-[0-9]{3}", na_pass = TRUE, actions = warn_on_fail() ) diff --git a/tests/testthat/test-interrogate_with_agent.R b/tests/testthat/test-interrogate_with_agent.R index c468a7953..7052cbfb4 100644 --- a/tests/testthat/test-interrogate_with_agent.R +++ b/tests/testthat/test-interrogate_with_agent.R @@ -1389,7 +1389,7 @@ test_that("Interrogating for valid row values", { create_agent(tbl = small_table) %>% col_vals_regex( columns = vars(b), - regex = "[0-9]-[a-z]{3}-[0-9]{3}" + pattern = "[0-9]-[a-z]{3}-[0-9]{3}" ) %>% interrogate() @@ -1413,7 +1413,7 @@ test_that("Interrogating for valid row values", { create_agent(tbl = small_table) %>% col_vals_regex( columns = vars(f), - regex = "[a-z]{3}", + pattern = "[a-z]{3}", preconditions = ~ . %>% dplyr::filter(f != "high") ) %>% interrogate() @@ -1567,12 +1567,12 @@ test_that("Interrogating with an agent incorporates the `na_pass` option", { all_passed() %>% expect_true() - # Use the `col_vals_gte()` function to perform + # Use the `col_vals_ge()` function to perform # a validation step with NAs, switching the # value of the `na_pass` option dplyr::tibble(a = c(1.0, 1.5, 2.5, NA)) %>% create_agent() %>% - col_vals_gte( + col_vals_ge( columns = vars(a), value = 1.0, na_pass = FALSE, @@ -1584,7 +1584,7 @@ test_that("Interrogating with an agent incorporates the `na_pass` option", { dplyr::tibble(a = c(1.0, 1.5, 2.5, NA)) %>% create_agent() %>% - col_vals_gte( + col_vals_ge( columns = vars(a), value = 1.0, na_pass = TRUE, @@ -1621,12 +1621,12 @@ test_that("Interrogating with an agent incorporates the `na_pass` option", { all_passed() %>% expect_true() - # Use the `col_vals_lte()` function to perform + # Use the `col_vals_le()` function to perform # a validation step with NAs, switching the # value of the `na_pass` option dplyr::tibble(a = c(1.0, 1.5, 2.5, NA)) %>% create_agent() %>% - col_vals_lte( + col_vals_le( columns = vars(a), value = 2.5, na_pass = FALSE, @@ -1638,7 +1638,7 @@ test_that("Interrogating with an agent incorporates the `na_pass` option", { dplyr::tibble(a = c(1.0, 1.5, 2.5, NA)) %>% create_agent() %>% - col_vals_lte( + col_vals_le( columns = vars(a), value = 2.5, na_pass = TRUE, @@ -1709,7 +1709,7 @@ test_that("Interrogating with an agent incorporates the `na_pass` option", { create_agent() %>% col_vals_regex( columns = vars(a), - regex = "[0-9]-[a-z]{3}-[0-9]{3}", + pattern = "[0-9]-[a-z]{3}-[0-9]{3}", na_pass = FALSE, actions = action_levels(warn = 1) ) %>% @@ -1721,7 +1721,7 @@ test_that("Interrogating with an agent incorporates the `na_pass` option", { create_agent() %>% col_vals_regex( columns = vars(a), - regex = "[0-9]-[a-z]{3}-[0-9]{3}", + pattern = "[0-9]-[a-z]{3}-[0-9]{3}", na_pass = TRUE, actions = action_levels(warn = 1) ) %>% @@ -1814,16 +1814,16 @@ test_that("Select validation steps can be `active` or not", { col_vals_between(columns = vars(d), left = 0, right = 5000) %>% col_vals_equal(columns = vars(d), value = 283.94) %>% col_vals_gt(columns = vars(date_time), value = vars(date)) %>% - col_vals_gte(columns = vars(date_time), value = vars(date)) %>% + col_vals_ge(columns = vars(date_time), value = vars(date)) %>% col_vals_lt(columns = vars(date_time), value = vars(date)) %>% - col_vals_lte(columns = vars(date_time), value = vars(date)) %>% + col_vals_le(columns = vars(date_time), value = vars(date)) %>% col_vals_in_set(columns = vars(f), set = c("low", "mid", "high")) %>% col_vals_not_between(columns = vars(d), left = 500, right = 1000) %>% col_vals_not_equal(columns = vars(d), value = 283.94) %>% col_vals_not_in_set(columns = vars(f), set = c("lower", "middle", "higher")) %>% col_vals_not_null(columns = vars(c)) %>% col_vals_null(columns = vars(b)) %>% - col_vals_regex(columns = vars(f), regex = "[a-z]{3}") %>% + col_vals_regex(columns = vars(f), pattern = "[a-z]{3}") %>% rows_distinct() %>% conjointly( ~ col_vals_gt(., columns = vars(a), value = 1), @@ -1873,16 +1873,16 @@ test_that("Select validation steps can be `active` or not", { col_vals_between(columns = vars(d), left = 0, right = 5000, active = FALSE) %>% col_vals_equal(columns = vars(d), value = 283.94, active = FALSE) %>% col_vals_gt(columns = vars(date_time), value = vars(date), active = FALSE) %>% - col_vals_gte(columns = vars(date_time), value = vars(date), active = FALSE) %>% + col_vals_ge(columns = vars(date_time), value = vars(date), active = FALSE) %>% col_vals_lt(columns = vars(date_time), value = vars(date), active = FALSE) %>% - col_vals_lte(columns = vars(date_time), value = vars(date), active = FALSE) %>% + col_vals_le(columns = vars(date_time), value = vars(date), active = FALSE) %>% col_vals_in_set(columns = vars(f), set = c("low", "mid", "high"), active = FALSE) %>% col_vals_not_between(columns = vars(d), left = 500, right = 1000, active = FALSE) %>% col_vals_not_equal(columns = vars(d), value = 283.94, active = FALSE) %>% col_vals_not_in_set(columns = vars(f), set = c("lower", "middle", "higher"), active = FALSE) %>% col_vals_not_null(columns = vars(c), active = FALSE) %>% col_vals_null(columns = vars(b), active = FALSE) %>% - col_vals_regex(columns = vars(f), regex = "[a-z]{3}", active = FALSE) %>% + col_vals_regex(columns = vars(f), pattern = "[a-z]{3}", active = FALSE) %>% rows_distinct(active = FALSE) %>% conjointly( ~ col_vals_gt(., columns = vars(a), value = 1), @@ -1938,16 +1938,16 @@ test_that("Select validation steps can be `active` or not", { col_vals_between(columns = vars(d), left = 0, right = 5000, actions = al) %>% col_vals_equal(columns = vars(d), value = 283.94, actions = al) %>% col_vals_gt(columns = vars(date_time), value = vars(date), actions = al) %>% - col_vals_gte(columns = vars(date_time), value = vars(date), actions = al) %>% + col_vals_ge(columns = vars(date_time), value = vars(date), actions = al) %>% col_vals_lt(columns = vars(date_time), value = vars(date), actions = al) %>% - col_vals_lte(columns = vars(date_time), value = vars(date), actions = al) %>% + col_vals_le(columns = vars(date_time), value = vars(date), actions = al) %>% col_vals_in_set(columns = vars(f), set = c("low", "mid", "high"), actions = al) %>% col_vals_not_between(columns = vars(d), left = 500, right = 1000, actions = al) %>% col_vals_not_equal(columns = vars(d), value = 283.94, actions = al) %>% col_vals_not_in_set(columns = vars(f), set = c("lower", "middle", "higher"), actions = al) %>% col_vals_not_null(columns = vars(c), actions = al) %>% col_vals_null(columns = vars(b), actions = al) %>% - col_vals_regex(columns = vars(f), regex = "[a-z]{3}", actions = al) %>% + col_vals_regex(columns = vars(f), pattern = "[a-z]{3}", actions = al) %>% rows_distinct(actions = al) %>% conjointly( ~ col_vals_gt(., columns = vars(a), value = 1), @@ -1985,16 +1985,16 @@ test_that("Select validation steps can be `active` or not", { col_vals_between(columns = vars(d), left = 0, right = 5000, actions = al, active = FALSE) %>% col_vals_equal(columns = vars(d), value = 283.94, actions = al, active = FALSE) %>% col_vals_gt(columns = vars(date_time), value = vars(date), actions = al, active = FALSE) %>% - col_vals_gte(columns = vars(date_time), value = vars(date), actions = al, active = FALSE) %>% + col_vals_ge(columns = vars(date_time), value = vars(date), actions = al, active = FALSE) %>% col_vals_lt(columns = vars(date_time), value = vars(date), actions = al, active = FALSE) %>% - col_vals_lte(columns = vars(date_time), value = vars(date), actions = al, active = FALSE) %>% + col_vals_le(columns = vars(date_time), value = vars(date), actions = al, active = FALSE) %>% col_vals_in_set(columns = vars(f), set = c("low", "mid", "high"), actions = al, active = FALSE) %>% col_vals_not_between(columns = vars(d), left = 500, right = 1000, actions = al, active = FALSE) %>% col_vals_not_equal(columns = vars(d), value = 283.94, actions = al, active = FALSE) %>% col_vals_not_in_set(columns = vars(f), set = c("lower", "middle", "higher"), actions = al, active = FALSE) %>% col_vals_not_null(columns = vars(c), actions = al, active = FALSE) %>% col_vals_null(columns = vars(b), actions = al, active = FALSE) %>% - col_vals_regex(columns = vars(f), regex = "[a-z]{3}", actions = al, active = FALSE) %>% + col_vals_regex(columns = vars(f), pattern = "[a-z]{3}", actions = al, active = FALSE) %>% rows_distinct(actions = al, active = FALSE) %>% conjointly( ~ col_vals_gt(., columns = vars(a), value = 1), diff --git a/tests/testthat/test-interrogate_with_agent_db.R b/tests/testthat/test-interrogate_with_agent_db.R index f6daf2671..2f2dbc0e0 100644 --- a/tests/testthat/test-interrogate_with_agent_db.R +++ b/tests/testthat/test-interrogate_with_agent_db.R @@ -920,13 +920,13 @@ test_that("Interrogating with an agent incorporates the `na_pass` option", { all_passed() %>% expect_true() - # Use the `col_vals_gte()` function to perform + # Use the `col_vals_ge()` function to perform # a validation step with NAs, switching the # value of the `na_pass` option small_table %>% dplyr::mutate(g = ifelse(!is.na(c), 1.5, NA_real_)) %>% create_agent() %>% - col_vals_gte( + col_vals_ge( columns = vars(g), value = 1.0, na_pass = FALSE, @@ -939,7 +939,7 @@ test_that("Interrogating with an agent incorporates the `na_pass` option", { small_table %>% dplyr::mutate(g = ifelse(!is.na(c), 1.5, NA_real_)) %>% create_agent() %>% - col_vals_gte( + col_vals_ge( columns = vars(g), value = 1.0, na_pass = TRUE, @@ -978,13 +978,13 @@ test_that("Interrogating with an agent incorporates the `na_pass` option", { all_passed() %>% expect_true() - # Use the `col_vals_lte()` function to perform + # Use the `col_vals_le()` function to perform # a validation step with NAs, switching the # value of the `na_pass` option small_table %>% dplyr::mutate(g = ifelse(!is.na(c), 1.5, NA_real_)) %>% create_agent() %>% - col_vals_lte( + col_vals_le( columns = vars(g), value = 1.5, na_pass = FALSE, @@ -997,7 +997,7 @@ test_that("Interrogating with an agent incorporates the `na_pass` option", { small_table %>% dplyr::mutate(g = ifelse(!is.na(c), 1.5, NA_real_)) %>% create_agent() %>% - col_vals_lte( + col_vals_le( columns = vars(g), value = 1.5, na_pass = TRUE, diff --git a/tests/testthat/test-interrogate_with_agent_segments.R b/tests/testthat/test-interrogate_with_agent_segments.R index db8fae4c2..b9e30e5f1 100644 --- a/tests/testthat/test-interrogate_with_agent_segments.R +++ b/tests/testthat/test-interrogate_with_agent_segments.R @@ -253,7 +253,7 @@ test_that("Agent interrogations with segments yields the correct results", { expect_equal(nrow(validation$validation_set), 2) # - # col_vals_lte + # col_vals_le # comparison_tbl <- @@ -265,11 +265,11 @@ test_that("Agent interrogations with segments yields the correct results", { b = c(rep(4, 5), rep(5, 10), rep(10, 5), rep(12, 10)) ) - # Use the `col_vals_lte()` function with `segments`, + # Use the `col_vals_le()` function with `segments`, # segmenting the data by two grouping values from a single column validation <- create_agent(tbl = comparison_tbl) %>% - col_vals_lte( + col_vals_le( columns = vars(b), value = 5, segments = a ~ c("group_1", "group_2")) %>% interrogate() @@ -364,7 +364,7 @@ test_that("Agent interrogations with segments yields the correct results", { expect_equal(nrow(validation$validation_set), 2) # - # col_vals_gte + # col_vals_ge # comparison_tbl <- @@ -376,11 +376,11 @@ test_that("Agent interrogations with segments yields the correct results", { b = c(rep(4, 5), rep(5, 10), rep(10, 5), rep(12, 10)) ) - # Use the `col_vals_gte()` function with `segments`, + # Use the `col_vals_ge()` function with `segments`, # segmenting the data by two grouping values from a single column validation <- create_agent(tbl = comparison_tbl) %>% - col_vals_gte( + col_vals_ge( columns = vars(b), value = 4, segments = a ~ c("group_1", "group_2")) %>% interrogate() @@ -762,7 +762,7 @@ test_that("Agent interrogations with segments yields the correct results", { validation <- create_agent(tbl = regex_tbl) %>% col_vals_regex( - columns = vars(b), regex = "[0-9]{5}", + columns = vars(b), pattern = "[0-9]{5}", segments = a ~ c("group_1", "group_2")) %>% interrogate() diff --git a/tests/testthat/test-test_fns.R b/tests/testthat/test-test_fns.R index 337f1cf5b..236b00473 100644 --- a/tests/testthat/test-test_fns.R +++ b/tests/testthat/test-test_fns.R @@ -65,15 +65,15 @@ test_that("pointblank expectation functions produce the correct results", { expect_false(test_col_vals_lt(tbl, columns = vars(d), value = 9900, threshold = 0.01)) # - # test_col_vals_lte() + # test_col_vals_le() # - expect_true(test_col_vals_lte(tbl, columns = vars(a), value = 8)) - expect_false(test_col_vals_lte(tbl, columns = vars(a), value = 7)) - expect_true(test_col_vals_lte(tbl, columns = vars(a), value = 7, threshold = 2)) - expect_true(test_col_vals_lte(tbl, columns = vars(a), value = 0, threshold = 1000)) - expect_false(test_col_vals_lte(tbl, columns = vars(a), value = 7, threshold = 1)) - expect_false(test_col_vals_lte(tbl, columns = vars(a), value = 7, threshold = 0.01)) + expect_true(test_col_vals_le(tbl, columns = vars(a), value = 8)) + expect_false(test_col_vals_le(tbl, columns = vars(a), value = 7)) + expect_true(test_col_vals_le(tbl, columns = vars(a), value = 7, threshold = 2)) + expect_true(test_col_vals_le(tbl, columns = vars(a), value = 0, threshold = 1000)) + expect_false(test_col_vals_le(tbl, columns = vars(a), value = 7, threshold = 1)) + expect_false(test_col_vals_le(tbl, columns = vars(a), value = 7, threshold = 0.01)) # # test_col_vals_equal() @@ -98,16 +98,16 @@ test_that("pointblank expectation functions produce the correct results", { expect_false(test_col_vals_not_equal(tbl_not_equal_c_3, columns = vars(c), value = 7, threshold = 0.01)) # - # test_col_vals_gte() + # test_col_vals_ge() # - expect_true(test_col_vals_gte(tbl, columns = vars(c), value = 0, na_pass = TRUE)) - expect_false(test_col_vals_gte(tbl, columns = vars(c), value = 0)) - expect_false(test_col_vals_gte(tbl, columns = vars(c), value = NA)) - expect_true(test_col_vals_gte(tbl, columns = vars(c), value = 8, na_pass = TRUE, threshold = 0.6)) - expect_true(test_col_vals_gte(tbl, columns = vars(c), value = 0, threshold = 1000)) - expect_false(test_col_vals_gte(tbl, columns = vars(c), value = 0, threshold = 1)) - expect_false(test_col_vals_gte(tbl, columns = vars(c), value = 0, threshold = 0.01)) + expect_true(test_col_vals_ge(tbl, columns = vars(c), value = 0, na_pass = TRUE)) + expect_false(test_col_vals_ge(tbl, columns = vars(c), value = 0)) + expect_false(test_col_vals_ge(tbl, columns = vars(c), value = NA)) + expect_true(test_col_vals_ge(tbl, columns = vars(c), value = 8, na_pass = TRUE, threshold = 0.6)) + expect_true(test_col_vals_ge(tbl, columns = vars(c), value = 0, threshold = 1000)) + expect_false(test_col_vals_ge(tbl, columns = vars(c), value = 0, threshold = 1)) + expect_false(test_col_vals_ge(tbl, columns = vars(c), value = 0, threshold = 0.01)) # # test_col_vals_gt() @@ -254,11 +254,11 @@ test_that("pointblank expectation functions produce the correct results", { # test_col_vals_regex() # - expect_true(test_col_vals_regex(tbl, vars(b), regex = "^[0-9]-[a-z]{3}-[0-9]{3}$")) - expect_false(test_col_vals_regex(tbl, vars(b), regex = "^[0-9]-[a-z]{4}-[0-9]{3}$")) - expect_true(test_col_vals_regex(tbl, vars(b), regex = "^[0-9]-[a-z]{4}-[0-9]{3}$", threshold = 1000)) - expect_false(test_col_vals_regex(tbl, vars(b), regex = "^[0-9]-[a-z]{4}-[0-9]{3}$", threshold = 1)) - expect_false(test_col_vals_regex(tbl, vars(b), regex = "^[0-9]-[a-z]{4}-[0-9]{3}$", threshold = 0.01)) + expect_true(test_col_vals_regex(tbl, vars(b), pattern = "^[0-9]-[a-z]{3}-[0-9]{3}$")) + expect_false(test_col_vals_regex(tbl, vars(b), pattern = "^[0-9]-[a-z]{4}-[0-9]{3}$")) + expect_true(test_col_vals_regex(tbl, vars(b), pattern = "^[0-9]-[a-z]{4}-[0-9]{3}$", threshold = 1000)) + expect_false(test_col_vals_regex(tbl, vars(b), pattern = "^[0-9]-[a-z]{4}-[0-9]{3}$", threshold = 1)) + expect_false(test_col_vals_regex(tbl, vars(b), pattern = "^[0-9]-[a-z]{4}-[0-9]{3}$", threshold = 0.01)) # # test_col_vals_within_spec() @@ -792,10 +792,10 @@ test_that("expect errors to be expressed by pointblank under some conditions", { # Errors caught and expressed when a column doesn't exist expect_error(test_col_vals_lt(tbl, columns = vars(z), value = 0), regexp = no_col_msg) - expect_error(test_col_vals_lte(tbl, columns = vars(z), value = 0), regexp = no_col_msg) + expect_error(test_col_vals_le(tbl, columns = vars(z), value = 0), regexp = no_col_msg) expect_error(test_col_vals_equal(tbl, columns = vars(z), value = 3), regexp = no_col_msg) expect_error(test_col_vals_not_equal(tbl, columns = vars(z), value = 3), regexp = no_col_msg) - expect_error(test_col_vals_gte(tbl, columns = vars(z), value = 0), regexp = no_col_msg) + expect_error(test_col_vals_ge(tbl, columns = vars(z), value = 0), regexp = no_col_msg) expect_error(test_col_vals_gt(tbl, columns = vars(z), value = 0), regexp = no_col_msg) expect_error(test_col_vals_between(tbl, columns = vars(z), left = 0, right = 10000), regexp = no_col_msg) expect_error(test_col_vals_not_between(tbl, columns = vars(z), left = 0, right = 10000), regexp = no_col_msg) @@ -807,7 +807,7 @@ test_that("expect errors to be expressed by pointblank under some conditions", { expect_error(test_col_vals_decreasing(tbl, columns = vars(z)), regexp = no_col_msg) expect_error(test_col_vals_null(tbl, columns = vars(z)), regexp = no_col_msg) expect_error(test_col_vals_not_null(tbl, columns = vars(z)), regexp = no_col_msg) - expect_error(test_col_vals_regex(tbl, vars(z), regex = "^[0-9]-[a-z]{3}-[0-9]{3}$"), regexp = no_col_msg) + expect_error(test_col_vals_regex(tbl, vars(z), pattern = "^[0-9]-[a-z]{3}-[0-9]{3}$"), regexp = no_col_msg) expect_error(test_col_vals_within_spec(tbl, vars(z), spec = "email"), regexp = no_col_msg) expect_error(test_col_is_character(tbl, columns = vars(z)), regexp = no_col_msg) expect_error(test_col_is_numeric(tbl, columns = vars(z)), regexp = no_col_msg) diff --git a/tests/testthat/test-tidyselect_fails_safely_batch.R b/tests/testthat/test-tidyselect_fails_safely_batch.R index c1c500b09..ae84f9676 100644 --- a/tests/testthat/test-tidyselect_fails_safely_batch.R +++ b/tests/testthat/test-tidyselect_fails_safely_batch.R @@ -59,10 +59,10 @@ test_that("`col_*()`s show expected column selection failure/success behavior", select_expr <- select_exprs[[expr_name]] agent %>% col_vals_lt({{ select_expr }}, value = 5) %>% check_behaviors(expr_name) - agent %>% col_vals_lte({{ select_expr }}, value = 5) %>% check_behaviors(expr_name) + agent %>% col_vals_le({{ select_expr }}, value = 5) %>% check_behaviors(expr_name) agent %>% col_vals_equal({{ select_expr }}, value = 5) %>% check_behaviors(expr_name) agent %>% col_vals_not_equal({{ select_expr }}, value = 5) %>% check_behaviors(expr_name) - agent %>% col_vals_gte({{ select_expr }}, value = 5) %>% check_behaviors(expr_name) + agent %>% col_vals_ge({{ select_expr }}, value = 5) %>% check_behaviors(expr_name) agent %>% col_vals_gt({{ select_expr }}, value = 5) %>% check_behaviors(expr_name) agent %>% col_vals_between({{ select_expr }}, 2, 5) %>% check_behaviors(expr_name) agent %>% col_vals_not_between({{ select_expr }}, 2, 5) %>% check_behaviors(expr_name) @@ -74,7 +74,7 @@ test_that("`col_*()`s show expected column selection failure/success behavior", agent %>% col_vals_not_null({{ select_expr }}) %>% check_behaviors(expr_name) agent %>% col_vals_increasing({{ select_expr }}) %>% check_behaviors(expr_name) agent %>% col_vals_decreasing({{ select_expr }}) %>% check_behaviors(expr_name) - agent %>% col_vals_regex({{ select_expr }}, regex = "abc") %>% check_behaviors(expr_name) + agent %>% col_vals_regex({{ select_expr }}, pattern = "abc") %>% check_behaviors(expr_name) agent %>% col_vals_within_spec({{ select_expr }}, spec = "email") %>% check_behaviors(expr_name) agent %>% col_is_character({{ select_expr }}) %>% check_behaviors(expr_name) agent %>% col_is_numeric({{ select_expr }}) %>% check_behaviors(expr_name) diff --git a/tests/testthat/test-util_functions.R b/tests/testthat/test-util_functions.R index 01977eca4..fb32b4f44 100644 --- a/tests/testthat/test-util_functions.R +++ b/tests/testthat/test-util_functions.R @@ -62,7 +62,7 @@ test_that("Utility functions won't fail us", { # function to create an agent with one validation step agent <- create_agent(tbl = small_table) %>% - col_vals_regex(columns = vars(b), regex = "[0-9]-[a-z]*?-[0-9]*?") + col_vals_regex(columns = vars(b), pattern = "[0-9]-[a-z]*?-[0-9]*?") agent %>% get_values_at_idx(idx = 1) %>% expect_type("character") agent %>% get_values_at_idx(idx = 1) %>% expect_equal("[0-9]-[a-z]*?-[0-9]*?") @@ -265,7 +265,7 @@ test_that("Utility functions won't fail us", { col_vals_expr(expr(c %% 1 == 0)) %>% col_vals_gt(vars(date_time), vars(date), na_pass = TRUE) %>% col_vals_gt(vars(b), vars(g), na_pass = TRUE) %>% - col_vals_gte(vars(a, b, d), 0, na_pass = TRUE) %>% + col_vals_ge(vars(a, b, d), 0, na_pass = TRUE) %>% col_vals_regex(vars(b), "[1-9]-[a-z]{3}-[0-9]{3}") %>% rows_distinct() %>% col_vals_gt(vars(d), 100) %>% @@ -678,10 +678,10 @@ test_that("Utility functions won't fail us", { function_icons <- c( "col_vals_lt", - "col_vals_lte", + "col_vals_le", "col_vals_equal", "col_vals_not_equal", - "col_vals_gte", + "col_vals_ge", "col_vals_gt", "col_vals_between", "col_vals_not_between", diff --git a/tests/testthat/test-yaml.R b/tests/testthat/test-yaml.R index cbcd314a4..661c5ba84 100644 --- a/tests/testthat/test-yaml.R +++ b/tests/testthat/test-yaml.R @@ -28,7 +28,7 @@ test_that("YAML writing and reading works as expected", { col_vals_equal(vars(d), vars(d), na_pass = TRUE) %>% col_vals_null(vars(c)) %>% col_vals_not_null(matches("^.$")) %>% - col_vals_regex("b", regex = "[0-9]-[a-z]{3}-[0-9]{3}") %>% + col_vals_regex("b", pattern = "[0-9]-[a-z]{3}-[0-9]{3}") %>% col_is_character(vars(b)) %>% col_exists(vars(a, b)) %>% col_vals_expr(expr(a %% 1 == 0)) %>% @@ -692,12 +692,12 @@ test_that("Individual validation steps make the YAML round-trip successfully", { # expect_equal( - get_oneline_expr_str(agent %>% col_vals_regex(vars(b), regex = "[0-9]-[a-z]{3}-[0-9]{3}")), - "col_vals_regex(columns = vars(b),regex = \"[0-9]-[a-z]{3}-[0-9]{3}\")" + get_oneline_expr_str(agent %>% col_vals_regex(vars(b), pattern = "[0-9]-[a-z]{3}-[0-9]{3}")), + "col_vals_regex(columns = vars(b),pattern = \"[0-9]-[a-z]{3}-[0-9]{3}\")" ) expect_equal( - get_oneline_expr_str(agent %>% col_vals_regex(vars(b), regex = "[0-9]-[a-z]{3}-[0-9]{3}", label = "my_label")), - "col_vals_regex(columns = vars(b),regex = \"[0-9]-[a-z]{3}-[0-9]{3}\",label = \"my_label\")" + get_oneline_expr_str(agent %>% col_vals_regex(vars(b), pattern = "[0-9]-[a-z]{3}-[0-9]{3}", label = "my_label")), + "col_vals_regex(columns = vars(b),pattern = \"[0-9]-[a-z]{3}-[0-9]{3}\",label = \"my_label\")" ) # diff --git a/tests/testthat/tests_rds_files/agent-table_test.yaml b/tests/testthat/tests_rds_files/agent-table_test.yaml index 660b80fba..cd1719d29 100644 --- a/tests/testthat/tests_rds_files/agent-table_test.yaml +++ b/tests/testthat/tests_rds_files/agent-table_test.yaml @@ -8,7 +8,7 @@ locale: en steps: - col_vals_not_null: columns: vars(a) -- col_vals_lte: +- col_vals_le: columns: vars(a) value: 10.0 - col_vals_gt: