pub struct ParamLayout { /* private fields */ }Expand description
Validated parameter ordering and mapping between full and free values.
Implementations§
Source§impl ParamLayout
impl ParamLayout
Sourcepub fn new<S>(specs: impl IntoIterator<Item = S>) -> ParamResult<Self>
pub fn new<S>(specs: impl IntoIterator<Item = S>) -> ParamResult<Self>
Validates parameter definitions and constructs a layout.
§Errors
Returns ParamError when a definition has an empty or duplicate
name, invalid bounds, invalid periodic metadata, an invalid scale, or
an initial or fixed value outside its permitted domain.
Sourcepub fn id(&self, name: &str) -> Option<ParamId>
pub fn id(&self, name: &str) -> Option<ParamId>
Looks up a full-layout identifier by parameter name.
Sourcepub fn name(&self, id: ParamId) -> ParamResult<&str>
pub fn name(&self, id: ParamId) -> ParamResult<&str>
Returns the name associated with a full-layout identifier.
§Errors
Returns ParamError::InvalidParamId when id is outside this
layout.
Sourcepub fn spec(&self, id: ParamId) -> ParamResult<&Parameter>
pub fn spec(&self, id: ParamId) -> ParamResult<&Parameter>
Returns the definition associated with a full-layout identifier.
§Errors
Returns ParamError::InvalidParamId when id is outside this
layout.
Sourcepub fn free_id(&self, id: ParamId) -> ParamResult<Option<FreeParamId>>
pub fn free_id(&self, id: ParamId) -> ParamResult<Option<FreeParamId>>
Maps a full-layout identifier to free-parameter order.
Fixed parameters return None.
§Errors
Returns ParamError::InvalidParamId when id is outside this
layout.
Sourcepub fn free_params(&self) -> &[ParamId]
pub fn free_params(&self) -> &[ParamId]
Returns full-layout identifiers in free-parameter order.
Sourcepub fn default_values(&self) -> ParamValues
pub fn default_values(&self) -> ParamValues
Creates a full value set using fixed and deterministic initial values.
Sourcepub fn initial_free_values(&self) -> Vec<f64>
pub fn initial_free_values(&self) -> Vec<f64>
Return deterministic initial values in free-parameter order.
Uniform initial ranges use their midpoint.
Sourcepub fn values(&self, free: &[f64]) -> ParamResult<ParamValues>
pub fn values(&self, free: &[f64]) -> ParamResult<ParamValues>
Expand a free-parameter slice while restoring fixed values from the layout.
§Errors
Returns ParamError::FreeLengthMismatch when free does not contain
exactly one value per free parameter.
Sourcepub fn free_values_with(&self, value: impl FnMut(&Parameter) -> f64) -> Vec<f64>
pub fn free_values_with(&self, value: impl FnMut(&Parameter) -> f64) -> Vec<f64>
Generate one value per free parameter in layout order.
Sourcepub fn sample_initial(&self, seed: u64) -> Vec<f64>
pub fn sample_initial(&self, seed: u64) -> Vec<f64>
Generate initial free values, invoking uniform only for uniform initial ranges.
Sourcepub fn validate_free_values(&self, free: &[f64]) -> ParamResult<()>
pub fn validate_free_values(&self, free: &[f64]) -> ParamResult<()>
Validate free values against ordinary bounds and canonical periodic domains.
§Errors
Returns ParamError::FreeLengthMismatch when free has the wrong
length, or a value-related ParamError when a value lies outside its
parameter’s bounds or canonical periodic domain.
Sourcepub fn wrap_periodic_free_values(&self, free: &[f64]) -> ParamResult<Vec<f64>>
pub fn wrap_periodic_free_values(&self, free: &[f64]) -> ParamResult<Vec<f64>>
Return free values with periodic parameters mapped into their canonical domains. Non-periodic values are unchanged; ordinary bounds are not clamped.
§Errors
Returns ParamError::FreeLengthMismatch when free does not contain
exactly one value per free parameter.
Trait Implementations§
Source§impl Clone for ParamLayout
impl Clone for ParamLayout
Source§fn clone(&self) -> ParamLayout
fn clone(&self) -> ParamLayout
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more