Skip to content

Commit

Permalink
fix bug that happens inside baRulho
Browse files Browse the repository at this point in the history
  • Loading branch information
maRce10 committed Jul 24, 2023
1 parent 8872e14 commit c392662
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ docs/
tests/testthat/Rplots.pdf
..Rcheck/
.RData
ohun_0.1.1.tar.gz
9 changes: 4 additions & 5 deletions R/internal_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ ohun_style <-



# internal function to find (and plot) templates in the acoustic space
# internal function to find (and plot) templates in the acoustic space used by get_templates()
find_templates <-
function(reference = NULL,
n.sub.spaces,
Expand Down Expand Up @@ -285,7 +285,7 @@ pairs_iou <- function(df, detection, reference) {

.onAttach <-
function(libname, pkgname) {
packageStartupMessage("\nPlease cite as: \n")
packageStartupMessage("\nPlease cite 'ohun' as: \n")
packageStartupMessage(" Araya-Salas, M., Smith-Vidaurre, G., Chaverri, G., Brenes, J. C., Chirino, F., Elizondo-Calvo, J., & Rico-Guevara, A. 2023. ohun: an R package for diagnosing and optimizing automatic sound event detection. Methods in Ecology and Evolution. https://doi.org/10.1111/2041-210X.14170")
}

Expand All @@ -301,7 +301,7 @@ assert_unique_sels <- checkmate::makeAssertionFunction(check_unique_sels)

## function to check arguments
check_arguments <- function(fun, args){

# create object to store check results
check_collection <- checkmate::makeAssertCollection()

Expand Down Expand Up @@ -392,13 +392,12 @@ check_arguments <- function(fun, args){
checkmate::assert_numeric(x = args$smooth, any.missing = FALSE, all.missing = FALSE, unique = TRUE, lower = 0.0001, add = check_collection, .var.name = "smooth")

if (any(names(args) == "threshold")){
if (as.character(fun) %in% c("energy_detector", "optimize_energy_detector"))
if (as.character(fun)[[1]] %in% c("energy_detector", "optimize_energy_detector"))
checkmate::assert_numeric(x = args$threshold, any.missing = FALSE, all.missing = FALSE, unique = TRUE, lower = 0.0001, upper = 99.9, add = check_collection, .var.name = "threshold")
if (as.character(fun) %in% c("template_detector", "optimize_template_detector"))
checkmate::assert_numeric(x = args$threshold, any.missing = FALSE, all.missing = FALSE, unique = TRUE, lower = 0.0001, upper = 0.999, add = check_collection, .var.name = "threshold")
}


if (any(names(args) == "peak.amplitude"))
checkmate::assert_numeric(x = args$peak.amplitude, any.missing = FALSE, all.missing = FALSE, unique = TRUE, lower = 0, add = check_collection, .var.name = "peak.amplitude")

Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-energy_detector.R
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ test_that("using hold time", {
path = tempdir(),
pb = FALSE
)
expect_class(detec1, "data.frame")
expect_class(detec1, "selection_table")
expect_class(detec2, "data.frame")
expect_class(detec2, "selection_table")
expect_equal(nrow(detec2), 4)

})
Expand Down

0 comments on commit c392662

Please sign in to comment.