Skip to content
Merged
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
23 changes: 11 additions & 12 deletions R/convert_output.R
Original file line number Diff line number Diff line change
Expand Up @@ -475,12 +475,7 @@ convert_output <- function(
if ("sexes" %in% colnames(df3)) {
df3 <- df3 |>
# add in case if sexes is present and add sex as na if so
dplyr::mutate(
sex = dplyr::case_when(
any(grepl("^sexes$", colnames(df3))) ~ sexes,
TRUE ~ NA
)
) |>
dplyr::mutate(sex = if (any(grepl("^sexes$", colnames(df3)))) sexes else NA) |>
dplyr::select(-sexes)
} else {
df3 <- dplyr::mutate(df3, sex = NA)
Expand Down Expand Up @@ -667,7 +662,7 @@ convert_output <- function(
label == "f" ~ "fishing_mortality",
TRUE ~ label
),
estimate = as.numeric(estimate)
estimate = suppressWarnings(as.numeric(estimate))
# dplyr::if_else(
# grepl("-|_", as.numeric(estimate)),
# NA,
Expand Down Expand Up @@ -1425,10 +1420,7 @@ convert_output <- function(
out_new <- Reduce(rbind, out_list)
out_new <- out_new |>
dplyr::mutate(
fleet = dplyr::case_when(
any(unique(out_new$fleet) %in% fleet_names) ~ fleet,
TRUE ~ fleet_names[fleet]
),
fleet = if (any(unique(out_new$fleet) %in% fleet_names)) fleet else fleet_names[fleet],
era = dplyr::case_when(
!is.na(era) ~ era,
year < start_year ~ "init",
Expand Down Expand Up @@ -2395,7 +2387,14 @@ convert_output <- function(
var_names_sheet <- var_names_sheet |> dplyr::select(-module_name)
out_new <- dplyr::left_join(out_new, var_names_sheet, by = "label")
} else {
out_new <- dplyr::left_join(out_new, var_names_sheet, by = c("module_name", "label"))
var_names_sheet <- var_names_sheet |>
dplyr::distinct(module_name, label, .keep_all = TRUE)
out_new <- dplyr::left_join(
out_new,
var_names_sheet,
by = c("module_name", "label"),
relationship = "many-to-one"
)
}
out_new <- out_new |>
dplyr::mutate(label = dplyr::case_when(
Expand Down
5 changes: 1 addition & 4 deletions R/utils_plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -375,10 +375,7 @@ plot_aa <- function(
dplyr::mutate(
age = as.numeric(age),
# zvar = .data[[z]],
zvar = dplyr::case_when(
proportional ~ sqrt(.data[[z]]),
TRUE ~ .data[[z]]
)
zvar = if (proportional) sqrt(.data[[z]]) else .data[[z]]
)
# Caclaulate x-axis breaks
x_n_breaks <- axis_breaks(dat[[x]])
Expand Down
6 changes: 6 additions & 0 deletions tests/testthat/test-convert_output.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ test_that("convert_output works for SS3", {
expect_equal(dim(output)[2], 34)
})

test_that("convert_output does not emit scalar case_when deprecation warning", {
expect_no_warning(convert_output(
file = fs::path("fixtures", "ss3_models", "models", "Hake_2018", "Report.sso")
))
})


test_that("convert_output saves model ss3 hake output file", {
dir.create(fs::path("fixtures", "ss3_models_converted", "Hake_2018"), recursive = TRUE)
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-utils_plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ test_that("plot_aa and helper line builders return expected outputs", {
group_var = "1"
)

proportional_plot <- plot_aa(aa_dat, proportional = TRUE)
expect_no_warning(proportional_plot <- plot_aa(aa_dat, proportional = TRUE))
expect_s3_class(proportional_plot, "gg")
expect_equal(proportional_plot$theme$legend.position, "none")

Expand Down
Loading