pub struct Spec {Show 20 fields
pub name: String,
pub description: String,
pub seed: u64,
pub batch: u64,
pub threads: usize,
pub confidence: f64,
pub grid: Grid,
pub fiber: Option<Value>,
pub link: Vec<Value>,
pub metrics: Value,
pub stop: Stop,
pub progress: bool,
pub skip_below: Option<SkipAfter>,
pub profile: bool,
pub csv: Option<PathBuf>,
pub json: Option<PathBuf>,
pub base_dir: Option<PathBuf>,
pub expect: Vec<Value>,
pub search: Option<SearchSpec>,
pub source: Value,
}Expand description
A parsed specification (see the module documentation for the format).
Fields§
§name: StringName of the campaign (it enters the seeds of the trials).
description: StringOne-line description.
seed: u64Base seed.
batch: u64Trials per batch.
threads: usizeWorker threads (0: all cores).
confidence: f64Confidence level of the reported intervals and of the precision targets of the stopping rule, in $(0, 1)$.
grid: GridThe conditions.
fiber: Option<Value>Defaults of the fibre blocks.
link: Vec<Value>The blocks of the link, before substitution.
metrics: ValueThe metrics, before substitution.
stop: StopThe stopping rule.
progress: boolPrint one line per condition.
skip_below: Option<SkipAfter>Skip the rest of a sweep below an error floor (callbacks: {skip_below: …}).
profile: boolTime every block of every trial (see Link::trial).
csv: Option<PathBuf>CSV output.
json: Option<PathBuf>JSON output.
base_dir: Option<PathBuf>Directory of the specification file (relative paths of the blocks).
expect: Vec<Value>The expected results (see verify), the fibre of their gn_snr_db theories
merged over the fiber of the specification.
search: Option<SearchSpec>The search of an operating point (see search), instead of the sweep.
source: ValueThe specification as parsed, recorded in the JSON report of every run.
Implementations§
Source§impl Spec
impl Spec
Sourcepub fn runner(&self, opts: &RunOptions) -> Runner
pub fn runner(&self, opts: &RunOptions) -> Runner
The runner of the specification: its seed, batch, threads, stopping rule,
confidence and source, its callbacks (the progress lines, skip_below) and its
loggers (the CSV and JSON reports), each overridden by opts when it gives one.
run runs it on the scenario of the specification; a front end that runs the
trials otherwise (the Python chains with Python blocks) runs it on its own
scenario.
§Examples
use comnum_spec::{RunOptions, Spec, SpecScenario};
let spec = Spec::from_yaml("name: t\nthreads: 2\nlink: [source]\nstop: {max_trials: 3}")?;
let opts = RunOptions { threads: Some(1), ..RunOptions::default() };
let r = spec.runner(&opts).run(&SpecScenario::new(&spec), &spec.grid)?;
assert_eq!(r[0].trials, 3);Source§impl Spec
impl Spec
Sourcepub fn from_json(v: Json) -> Result<Spec>
pub fn from_json(v: Json) -> Result<Spec>
Parse a specification from a JSON tree.
§Errors
Error::Config for a missing or unknown key, an invalid grid (a key given by
a case and by an axis, see Grid::check) or rule.
Sourcepub fn parse(text: &str, format: Format) -> Result<Spec>
pub fn parse(text: &str, format: Format) -> Result<Spec>
Parse a specification text.
§Errors
Error::Config for a syntax error or an invalid specification.
§Examples
use comnum_spec::{Format, Spec};
let spec = Spec::parse(r#"{"name": "t", "grid": {"x": [1, 2]}, "link": ["source"]}"#, Format::Json)?;
assert_eq!(spec.conditions().len(), 2);Sourcepub fn from_path(path: impl AsRef<Path>) -> Result<Spec>
pub fn from_path(path: impl AsRef<Path>) -> Result<Spec>
Read a specification file (.yaml, .yml, .json or .toml).
§Errors
Error::Io if the file cannot be read, Error::Config otherwise.
Sourcepub fn conditions(&self) -> Vec<Condition>
pub fn conditions(&self) -> Vec<Condition>
The conditions of the grid.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Spec
impl RefUnwindSafe for Spec
impl Send for Spec
impl Sync for Spec
impl Unpin for Spec
impl UnsafeUnpin for Spec
impl UnwindSafe for Spec
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more