pub struct StopSpec {
pub column: String,
pub comparison: Comparison,
pub min_tick: u64,
}Expand description
A stop condition as written, with its column given as text.
Fields§
§column: StringStat column name, or a bare vector or histogram label for its magnitude or total.
comparison: ComparisonTest that the column’s value has to pass to end the run.
min_tick: u64First tick at which the condition can end a run.
Implementations§
Source§impl StopSpec
impl StopSpec
Sourcepub fn parse(condition: &str, min_tick: u64) -> Result<Self, StopError>
pub fn parse(condition: &str, min_tick: u64) -> Result<Self, StopError>
Reads condition, such as Infected <= 0, to be checked from min_tick on.
The comparator is the last run of <, >, = and ! characters, and the column is the text before it,
trimmed. A column name can then hold spaces and comparator characters, as in Agents (k=3) <= 0.5.
A threshold holds no comparator character, so a condition written by StopSpec is parsed back into the same
spec.
§Errors
Returns StopError::MissingColumn for a condition that starts with its comparator, and
StopError::Comparison for one with no comparator or a threshold that is not a finite number.
Sourcepub fn check_threshold(&self) -> Result<(), StopError>
pub fn check_threshold(&self) -> Result<(), StopError>
Checks that the threshold is finite, as StopSpec::parse does for a condition written as text.
§Errors
Returns StopError::NonFiniteThreshold for a threshold that is infinite or NaN.
Sourcepub fn check_label(&self, stats: &[StatDescriptor]) -> Result<(), StopError>
pub fn check_label(&self, stats: &[StatDescriptor]) -> Result<(), StopError>
Checks the column against the stat labels a model declares, as ReducerSpec::check_label does.
§Errors
Returns StopError::UnknownColumn for a column that does not start with a stat label.