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

Aperta
#449 3 commenti 0 reazioni 2 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

@Schiano-NOAA ci sta già lavorando.

Dal 30/10/2026.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

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.

Lingua principale
R
Stelle
20
Fork
10
Merge medio
3g 19h
PR unite (30g)
23

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di nmfs-ost/stockplotr

Tutte le issue di nmfs-ost/stockplotr

Issue simili

Altre issue su R

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.