`table_biomass_abundance_catch` fails tests due to change in `example_data`

Abierto
#449 3 comentarios 0 reacciones 2 asignados Ver en GitHub

Los mantenedores suelen responder en 2 días

@Schiano-NOAA ya está trabajando en esto.

Desde el 30/10/2026.

Evaluación

Este issue todavía no se ha evaluado.

Descripción

bug

A change in the format of example_data introduced in https://github.com/nmfs-ost/stockplotr/commit/e74daf8cb3e7d3ab050f746209e1fb11f00335f7 results in table_biomass_abundance_catch failing. The new example_data results in sex specific values for abundance, which are not being aggregated by the the table function.

I believe the solution is:

if (x == "catch$|landings_observed") {
        extra_grouping <- check_grouping(filtered_data)[-grep("year|fleet", check_grouping(filtered_data))]
        
        filtered_data <- filtered_data |>
          dplyr::summarise(
            estimate = sum(as.numeric(estimate), na.rm = TRUE),
            estimate_upper = mean(as.numeric(estimate_upper), na.rm = TRUE),
            estimate_lower = mean(as.numeric(estimate_lower), na.rm = TRUE),
            uncertainty_label = unique(uncertainty_label),
            uncertainty = mean(uncertainty, na.rm = TRUE),
            .by = c(year, model, label)
          ) # |>
        # dplyr::ungroup()
} else if (x == "^abundance") {
        extra_grouping <- check_grouping(filtered_data)[-grep("year|sex", check_grouping(filtered_data))]
        
        filtered_data <- filtered_data |>
          dplyr::summarise(
            estimate = sum(as.numeric(estimate), na.rm = TRUE),
            estimate_upper = mean(as.numeric(estimate_upper), na.rm = TRUE),
            estimate_lower = mean(as.numeric(estimate_lower), na.rm = TRUE),
            uncertainty_label = unique(uncertainty_label),
            uncertainty = mean(uncertainty, na.rm = TRUE),
            .by = c(year, model, label)
          ) # |>
        # dplyr::ungroup()
} else {
         extra_grouping <- check_grouping(filtered_data)[-grep("year", check_grouping(filtered_data))]
}

specifically, the introduction of the else if (x=="^abundance") conditional.

If this fix is not desired, reverting the above commit leads to this function working as previously and all associated tests passing.

Lenguaje dominante
R
Estrellas
20
Forks
10
Merge medio
3 d 19 h
PR fusionados (30 d)
23

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de nmfs-ost/stockplotr

Todos los issues de nmfs-ost/stockplotr

Issues similares

Más issues de R

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.