Skip to main content

parse_growing

Function parse_growing 

pub fn parse_growing(spec: &str) -> Result<GrowingDistribution>
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 open set to None.

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

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

// A closed line is unaffected -- identical to `dsl::parse`.
let parsed2 = dsl::parse_growing("int(2, 512, log)")?;
assert_eq!(parsed2.distribution, dsl::parse("int(2, 512, log)")?);
assert!(parsed2.open.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). 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 public DSL module documentation for the full grammar. parse itself is untouched: a spec with no growth keyword parses to the identical Distribution, with open set to None.

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

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

// A closed line is unaffected -- identical to `dsl::parse`.
let parsed2 = dsl::parse_growing("int(2, 512, log)")?;
assert_eq!(parsed2.distribution, dsl::parse("int(2, 512, log)")?);
assert!(parsed2.open.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).