Skip to content

Commit

Permalink
Add verbose in get_dep_no_obs()
Browse files Browse the repository at this point in the history
  • Loading branch information
Rafnuss committed Jan 3, 2025
1 parent 0559ca0 commit 626810a
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 15 deletions.
3 changes: 2 additions & 1 deletion R/get_n_individuals.R
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ get_n_individuals <- function(package = NULL,

deployments_no_obs <- get_dep_no_obs(
package,
pred_in("deploymentID", deploymentID)
pred_in("deploymentID", deploymentID),
verbose = FALSE
)

# get number of individuals collected by each deployment for each species
Expand Down
3 changes: 2 additions & 1 deletion R/get_n_obs.R
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ get_n_obs <- function(package = NULL,

deployments_no_obs <- get_dep_no_obs(
package,
pred_in("deploymentID", deploymentID)
pred_in("deploymentID", deploymentID),
verbose = FALSE
)

# get number of observations collected by each deployment for each species
Expand Down
3 changes: 2 additions & 1 deletion R/get_n_species.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ get_n_species <- function(package = NULL,
# get deployments without observations among the filtered deployments
deployments_no_obs <- get_dep_no_obs(
package,
pred_in("deploymentID", deployments$deploymentID)
pred_in("deploymentID", deployments$deploymentID),
verbose = FALSE
)

# get species detected by each deployment after filtering
Expand Down
5 changes: 4 additions & 1 deletion R/zzz.R
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@ labelFormat_scale <- function(max_scale = NULL,
#'
#' @param package Camera trap data package object, as returned by
#' `read_camtrap_dp()`.
#' @param verbose Show (`TRUE`) or not (`FALSE`) the deployments
#' without observations.
#' @param datapkg Deprecated. Use `package` instead.
#' @param ... Filter predicates for filtering on deployments
#' @return A tibble data frame with deployments not linked to any observations.
Expand All @@ -185,6 +187,7 @@ labelFormat_scale <- function(max_scale = NULL,
#' get_dep_no_obs(mica)
get_dep_no_obs <- function(package = NULL,
...,
verbose = TRUE,
datapkg = lifecycle::deprecated()) {

# check input camera trap data package
Expand All @@ -208,7 +211,7 @@ get_dep_no_obs <- function(package = NULL,
dep_no_obs_ids <- dep_no_obs$deploymentID
n_dep_no_obs <- length(dep_no_obs_ids)

if (n_dep_no_obs > 0) {
if (n_dep_no_obs > 0 && verbose) {
max_print <- 20
# Suppress long messages
if (length(dep_no_obs_ids) > max_print) {
Expand Down
11 changes: 0 additions & 11 deletions tests/testthat/test-map_dep.R
Original file line number Diff line number Diff line change
Expand Up @@ -140,17 +140,6 @@ test_that("map_dep() can calculate and get feature values", {
" and\\1",
paste(no_obs_deployments, collapse = ", ")
)
suppressMessages(expect_message(
map_dep(mica, feature = "rai", species = "krakeend"),
glue::glue("There are 3 deployments without observations: {no_obs_deployments_str}"),
fixed = TRUE
))

suppressMessages(expect_message(
map_dep(mica, feature = "rai_individuals", species = "krakeend"),
glue::glue("There are 3 deployments without observations: {no_obs_deployments_str}"),
fixed = TRUE
))
expect_warning(
map_dep(mica, feature = "n_species", species = "krakeend"),
"`species` ignored for `feature = n_species`",
Expand Down

0 comments on commit 626810a

Please sign in to comment.