Skip to main content

parse_growing

Function parse_growing 

pub fn parse_growing(spec: &str) -> Result<(Distribution, Option<Open>)>
Expand description

Parses a growing DSL spec into a distribution and its optional growth policy – the parallel entry point that adds open, open=up, open=down, limit=<range> and around(...) on top of everything parse already accepts – see the module documentation for the full grammar. parse itself is untouched: a spec with no growth keyword parses to the identical Distribution, with None in the second slot.

use atune_core::space::{dsl, Distribution};

let (dist, open) = dsl::parse_growing("loguniform(1e-5, 1e-2, open=up, limit=..=1.0)")?;
assert_eq!(dist, Distribution::float_log(1e-5, 1e-2)?);
assert!(open.is_some());

// A closed line is unaffected -- identical to `dsl::parse`.
let (dist2, open2) = dsl::parse_growing("int(2, 512, log)")?;
assert_eq!(dist2, dsl::parse("int(2, 512, log)")?);
assert!(open2.is_none());

§Errors

Everything parse can return, plus Error::InvalidSpace for a malformed growth keyword and whatever Open::validate rejects (a categorical or boolean seed surfaces as Error::Unsupported).