pub struct CategoricalParameter {
pub name: String,
pub values: Vec<ParameterValue>,
pub ordered: bool,
pub default: Option<ParameterValue>,
pub description: Option<String>,
}Expand description
Categorical parameter definition with enhanced features
Fields§
§name: StringName of the parameter
values: Vec<ParameterValue>Possible values
ordered: boolWhether the categories have an ordering
default: Option<ParameterValue>Default value if any
description: Option<String>Description of the parameter
Implementations§
Source§impl CategoricalParameter
impl CategoricalParameter
Sourcepub fn new(name: String, values: Vec<ParameterValue>) -> Self
pub fn new(name: String, values: Vec<ParameterValue>) -> Self
Create a new categorical parameter
Sourcepub fn ordered(name: String, values: Vec<ParameterValue>) -> Self
pub fn ordered(name: String, values: Vec<ParameterValue>) -> Self
Create an ordered categorical parameter
Sourcepub fn with_default(self, default: ParameterValue) -> Self
pub fn with_default(self, default: ParameterValue) -> Self
Set default value
Sourcepub fn with_description(self, description: String) -> Self
pub fn with_description(self, description: String) -> Self
Set description
Sourcepub fn sample(&self, rng: &mut impl Rng) -> ParameterValue
pub fn sample(&self, rng: &mut impl Rng) -> ParameterValue
Sample a random value from this parameter
Sourcepub fn get_index(&self, value: &ParameterValue) -> Option<usize>
pub fn get_index(&self, value: &ParameterValue) -> Option<usize>
Get the index of a value (useful for ordered categories)
Sourcepub fn get_neighbors(&self, value: &ParameterValue) -> Vec<ParameterValue>
pub fn get_neighbors(&self, value: &ParameterValue) -> Vec<ParameterValue>
Get neighboring values for ordered categories
Trait Implementations§
Source§impl Clone for CategoricalParameter
impl Clone for CategoricalParameter
Source§fn clone(&self) -> CategoricalParameter
fn clone(&self) -> CategoricalParameter
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for CategoricalParameter
impl RefUnwindSafe for CategoricalParameter
impl Send for CategoricalParameter
impl Sync for CategoricalParameter
impl Unpin for CategoricalParameter
impl UnwindSafe for CategoricalParameter
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more