Skip to main content

ParamLayout

Struct ParamLayout 

Source
pub struct ParamLayout { /* private fields */ }
Expand description

Validated parameter ordering and mapping between full and free values.

Implementations§

Source§

impl ParamLayout

Source

pub fn new<S>(specs: impl IntoIterator<Item = S>) -> ParamResult<Self>
where S: Into<Parameter>,

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.

Source

pub fn specs(&self) -> &[Parameter]

Returns all parameter definitions in full-layout order.

Source

pub fn len(&self) -> usize

Returns the total number of free and fixed parameters.

Source

pub fn is_empty(&self) -> bool

Returns whether the layout contains no parameters.

Source

pub fn n_free(&self) -> usize

Returns the number of free parameters.

Source

pub fn id(&self, name: &str) -> Option<ParamId>

Looks up a full-layout identifier by parameter name.

Source

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.

Source

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.

Source

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.

Source

pub fn free_params(&self) -> &[ParamId]

Returns full-layout identifiers in free-parameter order.

Source

pub fn default_values(&self) -> ParamValues

Creates a full value set using fixed and deterministic initial values.

Source

pub fn initial_free_values(&self) -> Vec<f64>

Return deterministic initial values in free-parameter order.

Uniform initial ranges use their midpoint.

Source

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.

Source

pub fn free_values_with(&self, value: impl FnMut(&Parameter) -> f64) -> Vec<f64>

Generate one value per free parameter in layout order.

Source

pub fn sample_initial(&self, seed: u64) -> Vec<f64>

Generate initial free values, invoking uniform only for uniform initial ranges.

Source

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.

Source

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

Source§

fn clone(&self) -> ParamLayout

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ParamLayout

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for ParamLayout

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for ParamLayout

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.