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

Track additional field in validation set for brief type #590

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion R/col_exists.R
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ col_exists <- function(
actions = covert_actions(actions, agent),
step_id = step_id[i],
label = label[[i]],
brief = brief[[i]],
brief = brief[i],
active = active
)
}
Expand Down
2 changes: 1 addition & 1 deletion R/col_is_character.R
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ col_is_character <- function(
actions = covert_actions(actions, agent),
step_id = step_id[i],
label = label[[i]],
brief = brief[[i]],
brief = brief[i],
active = active
)
}
Expand Down
2 changes: 1 addition & 1 deletion R/col_is_date.R
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ col_is_date <- function(
actions = covert_actions(actions, agent),
step_id = step_id[i],
label = label[[i]],
brief = brief[[i]],
brief = brief[i],
active = active
)
}
Expand Down
2 changes: 1 addition & 1 deletion R/col_is_factor.R
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ col_is_factor <- function(
actions = covert_actions(actions, agent),
step_id = step_id[i],
label = label[[i]],
brief = brief[[i]],
brief = brief[i],
active = active
)
}
Expand Down
2 changes: 1 addition & 1 deletion R/col_is_integer.R
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ col_is_integer <- function(
actions = covert_actions(actions, agent),
step_id = step_id[i],
label = label[[i]],
brief = brief[[i]],
brief = brief[i],
active = active
)
}
Expand Down
2 changes: 1 addition & 1 deletion R/col_is_logical.R
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ col_is_logical <- function(
actions = covert_actions(actions, agent),
step_id = step_id[i],
label = label[[i]],
brief = brief[[i]],
brief = brief[i],
active = active
)
}
Expand Down
2 changes: 1 addition & 1 deletion R/col_is_numeric.R
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ col_is_numeric <- function(
actions = covert_actions(actions, agent),
step_id = step_id[i],
label = label[[i]],
brief = brief[[i]],
brief = brief[i],
active = active
)
}
Expand Down
2 changes: 1 addition & 1 deletion R/col_is_posix.R
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ col_is_posix <- function(
actions = covert_actions(actions, agent),
step_id = step_id[i],
label = label[[i]],
brief = brief[[i]],
brief = brief[i],
active = active
)
}
Expand Down
2 changes: 1 addition & 1 deletion R/col_vals_between.R
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ col_vals_between <- function(
actions = covert_actions(actions, agent),
step_id = step_id[i],
label = label[[i, j]],
brief = brief[[i, j]],
brief = brief[i, j],
active = active
)
}
Expand Down
2 changes: 1 addition & 1 deletion R/col_vals_decreasing.R
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ col_vals_decreasing <- function(
actions = covert_actions(actions, agent),
step_id = step_id[i],
label = label[[i, j]],
brief = brief[[i, j]],
brief = brief[i, j],
active = active
)
}
Expand Down
2 changes: 1 addition & 1 deletion R/col_vals_equal.R
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ col_vals_equal <- function(
actions = covert_actions(actions, agent),
step_id = step_id[i],
label = label[[i, j]],
brief = brief[[i, j]],
brief = brief[i, j],
active = active
)
}
Expand Down
2 changes: 1 addition & 1 deletion R/col_vals_expr.R
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ col_vals_expr <- function(
actions = covert_actions(actions, agent),
step_id = step_id,
label = label[[i]],
brief = brief[[i]],
brief = brief[i],
active = active
)
}
Expand Down
2 changes: 1 addition & 1 deletion R/col_vals_gt.R
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ col_vals_gt <- function(
actions = covert_actions(actions, agent),
step_id = step_id[i],
label = label[[i, j]],
brief = brief[[i, j]],
brief = brief[i, j],
active = active
)
}
Expand Down
2 changes: 1 addition & 1 deletion R/col_vals_gte.R
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ col_vals_gte <- function(
actions = covert_actions(actions, agent),
step_id = step_id[i],
label = label[[i, j]],
brief = brief[[i, j]],
brief = brief[i, j],
active = active
)
}
Expand Down
2 changes: 1 addition & 1 deletion R/col_vals_in_set.R
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ col_vals_in_set <- function(
actions = covert_actions(actions, agent),
step_id = step_id[i],
label = label[[i, j]],
brief = brief[[i, j]],
brief = brief[i, j],
active = active
)
}
Expand Down
2 changes: 1 addition & 1 deletion R/col_vals_increasing.R
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ col_vals_increasing <- function(
actions = covert_actions(actions, agent),
step_id = step_id[i],
label = label[[i, j]],
brief = brief[[i, j]],
brief = brief[i, j],
active = active
)
}
Expand Down
2 changes: 1 addition & 1 deletion R/col_vals_lt.R
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ col_vals_lt <- function(
actions = covert_actions(actions, agent),
step_id = step_id[i],
label = label[[i, j]],
brief = brief[[i, j]],
brief = brief[i, j],
active = active
)
}
Expand Down
2 changes: 1 addition & 1 deletion R/col_vals_lte.R
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ col_vals_lte <- function(
actions = covert_actions(actions, agent),
step_id = step_id[i],
label = label[[i, j]],
brief = brief[[i, j]],
brief = brief[i, j],
active = active
)
}
Expand Down
2 changes: 1 addition & 1 deletion R/col_vals_make_set.R
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ col_vals_make_set <- function(
actions = covert_actions(actions, agent),
step_id = step_id[i],
label = label[[i, j]],
brief = brief[[i, j]],
brief = brief[i, j],
active = active
)
}
Expand Down
2 changes: 1 addition & 1 deletion R/col_vals_make_subset.R
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ col_vals_make_subset <- function(
actions = covert_actions(actions, agent),
step_id = step_id[i],
label = label[[i, j]],
brief = brief[[i, j]],
brief = brief[i, j],
active = active
)
}
Expand Down
2 changes: 1 addition & 1 deletion R/col_vals_not_between.R
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ col_vals_not_between <- function(
actions = covert_actions(actions, agent),
step_id = step_id[i],
label = label[[i, j]],
brief = brief[[i, j]],
brief = brief[i, j],
active = active
)
}
Expand Down
2 changes: 1 addition & 1 deletion R/col_vals_not_equal.R
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ col_vals_not_equal <- function(
actions = covert_actions(actions, agent),
step_id = step_id[i],
label = label[[i, j]],
brief = brief[[i, j]],
brief = brief[i, j],
active = active
)
}
Expand Down
2 changes: 1 addition & 1 deletion R/col_vals_not_in_set.R
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ col_vals_not_in_set <- function(
actions = covert_actions(actions, agent),
step_id = step_id[i],
label = label[[i, j]],
brief = brief[[i, j]],
brief = brief[i, j],
active = active
)
}
Expand Down
2 changes: 1 addition & 1 deletion R/col_vals_not_null.R
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ col_vals_not_null <- function(
actions = covert_actions(actions, agent),
step_id = step_id[i],
label = label[[i, j]],
brief = brief[[i, j]],
brief = brief[i, j],
active = active
)
}
Expand Down
2 changes: 1 addition & 1 deletion R/col_vals_null.R
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ col_vals_null <- function(
actions = covert_actions(actions, agent),
step_id = step_id[i],
label = label[[i, j]],
brief = brief[[i, j]],
brief = brief[i, j],
active = active
)
}
Expand Down
2 changes: 1 addition & 1 deletion R/col_vals_regex.R
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ col_vals_regex <- function(
actions = covert_actions(actions, agent),
step_id = step_id[i],
label = label[[i, j]],
brief = brief[[i, j]],
brief = brief[i, j],
active = active
)
}
Expand Down
2 changes: 1 addition & 1 deletion R/col_vals_within_spec.R
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ col_vals_within_spec <- function(
actions = covert_actions(actions, agent),
step_id = step_id[i],
label = label[[i, j]],
brief = brief[[i, j]],
brief = brief[i, j],
active = active
)
}
Expand Down
2 changes: 1 addition & 1 deletion R/conjointly.R
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ conjointly <- function(
actions = covert_actions(actions, agent),
step_id = step_id,
label = label[[i]],
brief = brief[[i]],
brief = brief[i],
active = active
)
}
Expand Down
2 changes: 1 addition & 1 deletion R/row_count_match.R
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ row_count_match <- function(
actions = covert_actions(actions, agent),
step_id = step_id,
label = label[[i]],
brief = brief[[i]],
brief = brief[i],
active = active
)
}
Expand Down
2 changes: 1 addition & 1 deletion R/rows_complete.R
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ rows_complete <- function(
actions = covert_actions(actions, agent),
step_id = step_id,
label = label[[i]],
brief = brief[[i]],
brief = brief[i],
active = active
)
}
Expand Down
2 changes: 1 addition & 1 deletion R/rows_distinct.R
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ rows_distinct <- function(
actions = covert_actions(actions, agent),
step_id = step_id,
label = label[[i]],
brief = brief[[i]],
brief = brief[i],
active = active
)
}
Expand Down
2 changes: 1 addition & 1 deletion R/serially.R
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@ serially <- function(
actions = covert_actions(actions, agent),
step_id = step_id,
label = label[[i]],
brief = brief[[i]],
brief = brief[i],
active = active
)
}
Expand Down
2 changes: 1 addition & 1 deletion R/specially.R
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ specially <- function(
actions = covert_actions(actions, agent),
step_id = step_id,
label = label[[i]],
brief = brief[[i]],
brief = brief[i],
active = active
)
}
Expand Down
1 change: 1 addition & 0 deletions R/steps_and_briefs.R
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ create_validation_step <- function(
actions = ifelse(is.null(actions), list(NULL), list(actions)),
label = ifelse(is.null(label), NA_character_, as.character(label)),
brief = ifelse(is.null(brief), NA_character_, as.character(brief)),
brief_cls = as.character(class(.env$brief)[1]),
active = ifelse(is.null(active), list(NULL), list(active)),
eval_active = NA,
eval_error = NA,
Expand Down
2 changes: 1 addition & 1 deletion R/tbl_match.R
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ tbl_match <- function(
actions = covert_actions(actions, agent),
step_id = step_id,
label = label[[i]],
brief = brief[[i]],
brief = brief[i],
active = active
)
}
Expand Down
19 changes: 17 additions & 2 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,9 @@
n_combinations <- n_columns * n_segments

# If missing, apply auto-brief
if (is.null(brief)) {
brief_cls <- class(brief)
use_autobrief <- is.null(brief)
if (use_autobrief) {
brief <- generate_autobriefs(
agent = agent, columns = columns,
preconditions = preconditions, values = values,
Expand All @@ -270,10 +272,23 @@
# Recycle the string
brief <- rep_len(brief, n_combinations)
# Return packed vector/matrix for iteration over steps
pack_by_col_seg(brief, n_columns, n_segments, c(columns, segments))
brief <- pack_by_col_seg(brief, n_columns, n_segments, c(columns, segments_list))

Check warning on line 275 in R/utils.R

View workflow job for this annotation

GitHub Actions / lint

file=R/utils.R,line=275,col=81,[line_length_linter] Lines should not be more than 80 characters. This line is 84 characters.

# Track brief type: one of autobrief, AsIs/verbatim, character
if (use_autobrief) {
class(brief) <- "autobrief"
} else if (any(c("AsIs", "verbatim") %in% brief_cls)) {
brief <- I(brief)
} else {
brief <- unclass(brief)
}

brief

}

`[.autobrief` <- function(x, i, ...) structure(NextMethod("["), class = "autobrief")

Check warning on line 290 in R/utils.R

View workflow job for this annotation

GitHub Actions / lint

file=R/utils.R,line=290,col=81,[line_length_linter] Lines should not be more than 80 characters. This line is 84 characters.

resolve_label <- function(label, columns = list(NULL), segments = list(NULL)) {
n_columns <- length(columns)
n_segments <- length(segments)
Expand Down
31 changes: 31 additions & 0 deletions tests/testthat/test-brief.R
Original file line number Diff line number Diff line change
Expand Up @@ -227,3 +227,34 @@ test_that("Briefs batch tests: special validations", {
)

})

test_that("brief_cls hosts information about class", {

get_brief_cls <- function(brief) {
create_agent(~ small_table) %>%
col_vals_gt(c(a, c), 5, brief = brief) %>%
el("validation_set") %>%
el("brief_cls")
}

expect_identical(
get_brief_cls("chr"),
rep("character", 2)
)

expect_identical(
get_brief_cls(NULL),
rep("autobrief", 2)
)

yml <- yaml::as.yaml(list(author = "June", id = 123))
expect_identical(
get_brief_cls(I(yml)),
rep("AsIs", 2)
)
expect_identical(
get_brief_cls(structure(yml, class = "verbatim")),
rep("AsIs", 2)
)

})
Loading
Loading