Validates that a fitter object correctly implements the bayesim Fitter interface. This function checks that the object is a valid S7 Fitter class instance with all required properties and methods implemented.
Usage
validate_fitter(
fitter,
smoke_test = FALSE,
verbose = FALSE,
data_bundle = NULL,
fit_spec = NULL,
task_ctx = NULL
)Arguments
- fitter
An S7 Fitter object to validate
- smoke_test
Logical, if TRUE run a quick fit test with sample data to verify that methods work correctly end-to-end
- verbose
Logical, if TRUE print progress messages during validation
- data_bundle
Optional representative data bundle for the conformance run. Supplying this is recommended for custom fitters whose data contract is not a
y ~ xregression.- fit_spec
Optional representative fit specification passed to
fit_model()during conformance testing.- task_ctx
Optional task context passed to
fit_model()during conformance testing.
Value
The validated fitter object (invisibly) if valid, otherwise raises an error with details about what failed
Details
The validation performs the following checks:
Property Checks:
Object is an S7 Fitter class
nameproperty exists and is charactersupports_predictionsproperty exists and is logicalsupports_log_likproperty exists and is logicalsupports_looproperty exists and is logicalsupports_epredproperty exists and is logical
Method Checks:
fit_model()andextract_draws()are implemented (the core contract)optional methods are required only when their
supports_*capability isTRUE; unsupported methods have safe defaultsfit_diagnostics()may use the default empty-list implementation
Smoke Test (when smoke_test = TRUE):
Creates simple lm-like test data
Calls
fit_model()and verifiesbayesim_fit_resultstructureCalls
extract_draws()and verifies matrix with colnamesIf
supports_predictions, callspredict_fit()and verifies outputIf
supports_log_lik, callslog_lik_matrix()and verifies matrix outputIf
supports_epred, callspredict_epred()and verifies matrix outputCalls
fit_diagnostics()and verifies list output
Examples
# Validate a built-in fitter (basic check only)
validate_fitter(LinearRegressionFitter())
# Full validation with an end-to-end smoke test
validate_fitter(LinearRegressionFitter(), smoke_test = TRUE)
if (FALSE) { # \dontrun{
# Use in your own fitter's tests
my_fitter <- MyCustomFitter()
validate_fitter(my_fitter, smoke_test = TRUE, verbose = TRUE)
} # }