Learn R Programming

sdbuildR (version 2.0.0)

discard_unit_test: Remove a unit test from a stock-and-flow model

Description

Remove one or more unit tests by test (integer position as shown by unit_tests()) or by label (character). Warns if a label or index is not found. Remaining tests are renumbered sequentially after removal.

Usage

discard_unit_test(object, label, test)

Value

The model object with the specified test(s) removed.

Arguments

object

Stock-and-flow model, object of class stockflow.

label

Character label(s) of the test(s) to remove. Supports NSE (bare symbol or string). For backward compatibility, integer values passed via label are also accepted.

test

Integer index/indices of the test(s) to remove. Corresponds to the order shown by unit_tests().

See Also

unit_test(), unit_tests()

Examples

Run this code
sfm <- stockflow("SIR") |>
  unit_test(label = "susceptible is non-negative", expr = all(susceptible >= 0)) |>
  unit_test(label = "recovered increases", expr = all(diff(recovered) >= 0))

# Remove by test
sfm <- discard_unit_test(sfm, test = 1)

# Remove by label
sfm <- discard_unit_test(sfm, label = "recovered increases")

Run the code above in your browser using DataLab