Skip to content

set_epi_outputs() produces warning. #351

@pwinskill

Description

@pwinskill

The following call:

p <- malariasimulation::get_parameters() |> 
  malariasimulation::set_epi_outputs(age_group = c(0, 100, 200))

Produces the following warning:

Warning message:
In any(lapply(list(n_with_hypnozoites, iaa, iam, hypnozoites), is.null)) :
  coercing argument of type 'list' to logical

Tracing this through it appears to be that the following section in set_epi_outputs() isn't happy:

if (parameters$parasite == "falciparum") {
    if (!any(lapply(list(n_with_hypnozoites, iaa, iam, hypnozoites), 
      is.null))) {
      stop("Some selected epi outputs do not apply to this parasite.")
    }
  }

Distilling it down I get the following simple example and possible fix

# Reprex of warning
bad_list <-  list(
  a = NULL,
  b = NULL
)
!any(lapply(bad_list, is.null))

# Possible fix
list <-  list(
  a = NULL,
  b = NULL
)
!any(sapply(bad_list, is.null))

@RJSheppard Maybe you could have a look as I think this is a modification that has come in with the pv changes?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions