Skip to content

Commit

Permalink
render documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
maRce10 committed Jul 7, 2023
1 parent 5db030f commit 91cb617
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
16 changes: 10 additions & 6 deletions R/internal_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,10 @@ check_arguments <- function(fun, args){
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")

if (any(names(args) == "thinning"))
checkmate::assert_numeric(x = args$thinning, any.missing = FALSE, all.missing = FALSE, unique = TRUE, lower = 0.0001, upper = 1, add = check_collection, .var.name = "thinning")

Expand Down Expand Up @@ -802,22 +806,22 @@ detect_FUN <-
}

# remove sound events based on duration
if (min.duration > 0) {
detections_df <- detections_df[detections_df$duration > min.duration / 1000, ]
if (min.dur > 0) {
detections_df <- detections_df[detections_df$duration > min.dur / 1000, ]
}
if (max.duration < Inf) {
detections_df <- detections_df[detections_df$duration < max.duration / 1000, ]
if (max.dur < Inf) {
detections_df <- detections_df[detections_df$duration < max.dur / 1000, ]
}
}

# remove extra column
detections_df$ovlp.sels <- NULL

# measure peak.amplitude
if (peak.amplitude > 0) {
if (pa > 0) {
detections_df <- warbleR::sound_pressure_level(detections_df, parallel = 1, path = pth, pb = FALSE, type = "peak")

detections_df <- detections_df[detections_df$SPL > peak.amplitude, ]
detections_df <- detections_df[detections_df$SPL > pa, ]

# remove extra column
detections_df$SPL <- NULL
Expand Down
1 change: 0 additions & 1 deletion man/energy_detector.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 3 additions & 5 deletions tests/testthat/test-energy_detector.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ test_that("peak amplitude works", {
)
expect_class(detec1, "data.frame")
expect_class(detec1, "selection_table")
expect_equal(nrow(detec1), 17)
expect_equal(nrow(detec1), 12)
})

test_that("time diagnostics", {
Expand All @@ -42,7 +42,7 @@ test_that("time diagnostics", {

expect_class(detec1, "data.frame")
expect_class(detec1, "selection_table")
expect_equal(nrow(detec1), 17)
expect_equal(nrow(detec1), 3)

})

Expand All @@ -59,7 +59,7 @@ test_that("using smoothing and minimum duration", {
)
expect_class(detec1, "data.frame")
expect_class(detec1, "selection_table")
expect_equal(nrow(detec1), 14)
expect_equal(nrow(detec1), 9)

})

Expand All @@ -80,8 +80,6 @@ test_that("using hold time", {

})



test_that("calculate envelopes first", {
envs <- get_envelopes(
files = c("lbh1.wav", "lbh2.wav"),
Expand Down

0 comments on commit 91cb617

Please sign in to comment.