Skip to content

Commit

Permalink
Appease linter
Browse files Browse the repository at this point in the history
  • Loading branch information
annakrystalli committed Jan 17, 2025
1 parent c711b49 commit 1b1effe
Showing 1 changed file with 153 additions and 151 deletions.
304 changes: 153 additions & 151 deletions tests/testthat/test-create_model_task.R
Original file line number Diff line number Diff line change
Expand Up @@ -216,173 +216,175 @@ test_that("create_output_type_point functions error correctly", {
withr::with_options(
list(
hubAdmin.schema_version = "v4.0.0"
), {
task_ids <- create_task_ids(
create_task_id("origin_date",
required = NULL,
optional = c(
"2023-01-02",
"2023-01-09",
"2023-01-16"
),
{
task_ids <- create_task_ids(
create_task_id("origin_date",
required = NULL,
optional = c(
"2023-01-02",
"2023-01-09",
"2023-01-16"
)
),
create_task_id("target",
required = NULL,
optional = c("inc death", "inc hosp")
),
create_task_id("horizon",
required = 1L,
optional = 2:4
)
),
create_task_id("target",
required = NULL,
optional = c("inc death", "inc hosp")
),
create_task_id("horizon",
required = 1L,
optional = 2:4
)
)
output_type <- create_output_type(
create_output_type_mean(
is_required = TRUE,
value_type = "double",
value_minimum = 0L
output_type <- create_output_type(
create_output_type_mean(
is_required = TRUE,
value_type = "double",
value_minimum = 0L
)
)
)
expect_snapshot(
create_model_task(
task_ids = task_ids,
output_type = output_type,
target_metadata = create_target_metadata(
create_target_metadata_item(
target_id = "inc hosp",
target_name = "Weekly incident influenza hospitalizations",
target_units = "rate per 100,000 population",
target_keys = list(target = "inc hosp"),
target_type = "discrete",
is_step_ahead = TRUE,
time_unit = "week"
expect_snapshot(
create_model_task(
task_ids = task_ids,
output_type = output_type,
target_metadata = create_target_metadata(
create_target_metadata_item(
target_id = "inc hosp",
target_name = "Weekly incident influenza hospitalizations",
target_units = "rate per 100,000 population",
target_keys = list(target = "inc hosp"),
target_type = "discrete",
is_step_ahead = TRUE,
time_unit = "week"
)
)
)
),
error = TRUE
)
expect_snapshot(
create_model_task(
task_ids = task_ids,
output_type = output_type,
target_metadata = create_target_metadata(
create_target_metadata_item(
target_id = "inc hosp",
target_name = "Weekly incident influenza hospitalizations",
target_units = "rate per 100,000 population",
target_keys = list(targets = "inc hosp"),
target_type = "discrete",
is_step_ahead = TRUE,
time_unit = "week"
),
error = TRUE
)
expect_snapshot(
create_model_task(
task_ids = task_ids,
output_type = output_type,
target_metadata = create_target_metadata(
create_target_metadata_item(
target_id = "inc hosp",
target_name = "Weekly incident influenza hospitalizations",
target_units = "rate per 100,000 population",
target_keys = list(targets = "inc hosp"),
target_type = "discrete",
is_step_ahead = TRUE,
time_unit = "week"
)
)
)
),
error = TRUE
)
),
error = TRUE
)

expect_snapshot(
create_model_task(
task_ids = task_ids,
output_type = list(a = 10),
target_metadata = create_target_metadata(
create_target_metadata_item(
target_id = "inc hosp",
target_name = "Weekly incident influenza hospitalizations",
target_units = "rate per 100,000 population",
target_keys = list(targets = "inc hosp"),
target_type = "discrete",
is_step_ahead = TRUE,
time_unit = "week"
expect_snapshot(
create_model_task(
task_ids = task_ids,
output_type = list(a = 10),
target_metadata = create_target_metadata(
create_target_metadata_item(
target_id = "inc hosp",
target_name = "Weekly incident influenza hospitalizations",
target_units = "rate per 100,000 population",
target_keys = list(targets = "inc hosp"),
target_type = "discrete",
is_step_ahead = TRUE,
time_unit = "week"
)
)
)
),
error = TRUE
)

task_ids <- create_task_ids(
create_task_id("origin_date",
required = NULL,
optional = c(
"2023-01-02",
"2023-01-09",
"2023-01-16"
)
),
create_task_id("horizon",
required = 1L,
optional = 2:4
),
error = TRUE
)
)

attr(task_ids, "schema_id") <- "invalid_schema_id"
expect_snapshot(
create_model_task(
task_ids = task_ids,
output_type = output_type,
target_metadata = create_target_metadata(
create_target_metadata_item(
target_id = "inc hosp",
target_name = "Weekly incident influenza hospitalizations",
target_units = "rate per 100,000 population",
target_keys = NULL,
target_type = "discrete",
is_step_ahead = TRUE,
time_unit = "week"
task_ids <- create_task_ids(
create_task_id("origin_date",
required = NULL,
optional = c(
"2023-01-02",
"2023-01-09",
"2023-01-16"
)
),
create_task_id("horizon",
required = 1L,
optional = 2:4
)
),
error = TRUE
)
)

expect_snapshot(
create_model_task(
task_ids = create_task_ids(
create_task_id("origin_date",
required = NULL,
optional = c(
"2023-01-02",
"2023-01-09",
"2023-01-16"
attr(task_ids, "schema_id") <- "invalid_schema_id"
expect_snapshot(
create_model_task(
task_ids = task_ids,
output_type = output_type,
target_metadata = create_target_metadata(
create_target_metadata_item(
target_id = "inc hosp",
target_name = "Weekly incident influenza hospitalizations",
target_units = "rate per 100,000 population",
target_keys = NULL,
target_type = "discrete",
is_step_ahead = TRUE,
time_unit = "week"
)
),
create_task_id("location",
required = "US",
optional = c("01", "02", "04", "05", "06")
),
create_task_id("horizon",
required = 1L,
optional = 2:4
)
),
output_type = create_output_type(
create_output_type_mean(
is_required = TRUE,
value_type = "double",
value_minimum = 0L
error = TRUE
)

expect_snapshot(
create_model_task(
task_ids = create_task_ids(
create_task_id("origin_date",
required = NULL,
optional = c(
"2023-01-02",
"2023-01-09",
"2023-01-16"
)
),
create_task_id("location",
required = "US",
optional = c("01", "02", "04", "05", "06")
),
create_task_id("horizon",
required = 1L,
optional = 2:4
)
),
create_output_type_sample(
is_required = FALSE,
output_type_id_type = "character",
max_length = 5L,
min_samples_per_task = 70L, max_samples_per_task = 100L,
compound_taskid_set = c("horizon", "random_task_id"),
value_type = "double",
value_minimum = 0L,
value_maximum = 1L
output_type = create_output_type(
create_output_type_mean(
is_required = TRUE,
value_type = "double",
value_minimum = 0L
),
create_output_type_sample(
is_required = FALSE,
output_type_id_type = "character",
max_length = 5L,
min_samples_per_task = 70L, max_samples_per_task = 100L,
compound_taskid_set = c("horizon", "random_task_id"),
value_type = "double",
value_minimum = 0L,
value_maximum = 1L
)
),
target_metadata = create_target_metadata(
create_target_metadata_item(
target_id = "inc hosp",
target_name = "Weekly incident influenza hospitalizations",
target_units = "rate per 100,000 population",
target_keys = NULL,
target_type = "discrete",
is_step_ahead = TRUE,
time_unit = "week"
)
)
),
target_metadata = create_target_metadata(
create_target_metadata_item(
target_id = "inc hosp",
target_name = "Weekly incident influenza hospitalizations",
target_units = "rate per 100,000 population",
target_keys = NULL,
target_type = "discrete",
is_step_ahead = TRUE,
time_unit = "week"
)
)
),
error = TRUE
)
})
error = TRUE
)
}
)
})

0 comments on commit 1b1effe

Please sign in to comment.