verify.stockflow: Verify unit tests against simulation results
Description
Run all active unit tests defined on a stock-and-flow model. Use
unit_test() to define tests; use unit_tests() to display them.
Usage
# S3 method for stockflow
verify(object, test = NULL, ...)
Value
An object of class verify_stockflow, returned invisibly. Use
as.data.frame() to extract results as a data frame and plot() to
visualize the simulations used. The object contains:
results
List of test result entries, one per test (including inactive
tests, which appear with status = "skip"). Each entry has label,
expr_str, conditions, status, error_type, message, and outcome.
object
The stockflow model the tests were run against.
sims
Nested list of simulate_stockflow objects used internally by
plot.verify_stockflow(). Always present (never NULL).
j
Named integer vector mapping each test label to its condition index.
Used internally by plot.verify_stockflow().
n
Number of simulations run per condition.
n_conditions
Number of unique simulation conditions.
test_indices
Integer vector of the original 1-based test numbers that
were run (as shown by unit_tests()). Equal to seq_along(results) when
test = NULL (all tests run).
Arguments
object
An stockflow object.
test
Integer vector of test number(s) to run (numbers-based, as shown by unit_tests()).
Defaults to NULL (run all tests).
...
Additional arguments passed to sim_settings() (e.g., seed,
dt).
Details
Calling verify() on a stockflow model will first simulate the model, then
run all tests — including those that require re-simulation under alternative
conditions. Simulations are always retained in the returned
object so that plot.verify_stockflow() works without any extra arguments.
For repeated-run robustness testing use ensemble() instead.