EOGrady21 / vprr

Video Plankton Recorder Data Processing
https://eogrady21.github.io/vprr/
Other
2 stars 1 forks source link

In vpr_autoid_create(), category ids are hardcoded into vpr_category(). Recommend including the category ids as an argument in vpr_autoid_create() #37

Closed kevinsorochan closed 1 year ago

kevinsorochan commented 1 year ago

Describe the bug

Category identifiers (e.g., copepod, ctenophore) are hardcoded into vpr_category(), which is called in vpr_autoid_create(). If different categories are used then those specified in vpr_category(), then the function will not work properly.

To Reproduce Reproducible code example of the bug, with output if appropriate.


#'taxa_ids' are hardcoded...

> vpr_category
function (x) 
{
    taxa_ids <- c("bad_image_blurry", "bad_image_malfunction", 
        "bad_image_strobe", "Calanus", "chaetognaths", 
        "ctenophores", "Echinoderm_larvae", "krill", 
        "marine_snow", "Other", "small_copepod", 
        "stick", "larval_fish", "other_copepods", 
        "larval_crab", "amphipod", "Metridia", 
        "Paraeuchaeta", "cnidarians")
    for (i in seq_len(length(taxa_ids))) {
        taxa_id <- taxa_ids[i]
        m_tmp <- gregexpr(taxa_id, x)
        if (m_tmp[[1]][1] > 0) {
            m <- m_tmp
        }
        else {
        }
    }
    y <- regmatches(x, m)
    return(y)
}

Expected behavior I expected that the categories would not be hardcoded

Screenshots If applicable, add screenshots to help explain your problem.

Session Info:

sessionInfo() R version 4.0.4 (2021-02-15) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 19042)

Matrix products: default

locale: [1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252

attached base packages: [1] stats graphics grDevices utils datasets methods base

other attached packages: [1] vprr_0.2.3

loaded via a namespace (and not attached): [1] Rcpp_1.0.8 pillar_1.8.1 compiler_4.0.4 tools_4.0.4
[5] digest_0.6.27 testthat_3.0.2 evaluate_0.14 lubridate_1.9.0
[9] lifecycle_1.0.3 tibble_3.1.8 oce_1.7-10 gtable_0.3.0
[13] checkmate_2.0.0 timechange_0.1.1 pkgconfig_2.0.3 rlang_1.0.6
[17] gsw_1.0-5 DBI_1.1.1 cli_3.4.1 rstudioapi_0.13
[21] yaml_2.2.1 xfun_0.22 fastmap_1.1.0 gridExtra_2.3
[25] knitr_1.33 metR_0.9.1 dplyr_1.0.6 generics_0.1.3
[29] vctrs_0.5.1 grid_4.0.4 tidyselect_1.2.0 glue_1.6.2
[33] data.table_1.14.0 R6_2.5.0 fansi_0.4.2 rmarkdown_2.14
[37] ggplot2_3.3.3 magrittr_2.0.1 htmltools_0.5.2 scales_1.1.1
[41] backports_1.2.1 assertthat_0.2.1 colorspace_2.0-1 utf8_1.2.1
[45] munsell_0.5.0

Additional context Add any other context about the problem here.

kevinsorochan commented 1 year ago

Recommendation - add a category argument to vpr_category(). Then set category = taxaNames in vpr_autoid_create().

kevinsorochan commented 1 year ago

The same problem occurs with use of vpr_category() in vpr_autoid_read()

EOGrady21 commented 1 year ago

Update to vpr_category was pushed through vpr_autoid_create and vpr_autoid_read.

All tests passing.