Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stricter input checking for proportion_transmission() #102

Merged
merged 16 commits into from
Sep 5, 2024
Merged

Conversation

joshwlambert
Copy link
Member

This PR tightens up the input checking in proportion_transmission().

proportion_transmission() now errors when:

  • the percent_transmission argument is equal to 0 or 1. Previously percent_transmission could be greater or equal to 0 and lesser than or equal to 1. When equal to 0 or 1, the function would produce invalid results (e.g. NaN) or would not produce sensible results due to numeric imprecision (e.g. percent_transmission = 0 when method = "t_20" was > 0). When percent_transmission was equal 1 the function would error when method = "t_20" and results for method = "p_80" would vastly differ depending on if simulate was TRUE or FALSE.
  • k is equal to 0. This produce errors weird behaviour similar to those outlined for percent_transmission.

Infinite values of k are approximated by setting them to 1e5. This was again due to errors and invalid results due to the inability of the internal proportion_transmission() methods not being able to work with Inf values.

The formatting of the proportion_transmission() and proportion_cluster_size() (when format_prop = TRUE which is the default) is now printed to 3 significant figures, rather than rounding, as values close to zero were being rounded to zero which could mislead users.

A new %gt% operator is added to the package to provide a succinct way to check if numeric variables are above a certain value and if so set than to the value with a message to the user. This operator is used in .prop_transmission_t20().

Unit tests are added to check the new input checking and variable setting, as well as for %gt%.

@joshwlambert joshwlambert added the enhancement New feature or request label Sep 5, 2024
@joshwlambert joshwlambert merged commit bb424ee into main Sep 5, 2024
7 checks passed
@joshwlambert joshwlambert deleted the inf-params branch September 5, 2024 11:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant