Skip to main content

parse_schema_growing

Function parse_schema_growing 

pub fn parse_schema_growing<I, N, S>(
    entries: I,
) -> Result<(SpaceSchema, SpacePolicy)>
where I: IntoIterator<Item = (N, S)>, N: Into<String>, S: AsRef<str>,
Expand description

Parses an ordered sequence of (name, spec) pairs into a SpaceSchema and the SpacePolicy its growth keywords declare – the growing counterpart of parse_schema. A parameter whose spec carries no growth keyword contributes nothing to the returned policy.

use atune_core::space::dsl;

let (schema, policy) = dsl::parse_schema_growing([
    ("lr", "loguniform(1e-5, 1e-2, open=up, limit=..=1.0)"),
    ("batch", "int(16, 512, step=16)"),
])?;
assert_eq!(schema.names().collect::<Vec<_>>(), ["lr", "batch"]);
assert!(policy.get("lr").is_some());
assert!(policy.get("batch").is_none());

§Errors

As parse_schema, plus whatever parse_growing and Open::validate reject.