pub struct Grid { /* private fields */ }Expand description
A grid of conditions (see the module documentation).
Implementations§
Source§impl Grid
impl Grid
Sourcepub fn from_conditions(conditions: Vec<Condition>) -> Grid
pub fn from_conditions(conditions: Vec<Condition>) -> Grid
An explicit list of conditions.
Sourcepub fn axis<V: Into<Value>>(
self,
name: &str,
values: impl IntoIterator<Item = V>,
) -> Grid
pub fn axis<V: Into<Value>>( self, name: &str, values: impl IntoIterator<Item = V>, ) -> Grid
Add an axis of values.
Sourcepub fn zip(self, names: &[&str], rows: Vec<Vec<Value>>) -> Result<Grid>
pub fn zip(self, names: &[&str], rows: Vec<Vec<Value>>) -> Result<Grid>
Add axes that vary together: rows[i] gives one value per name.
§Errors
Error::Shape if a row does not have one value per name.
§Examples
use comnum_sim::grid::Grid;
let g = Grid::new().zip(&["m", "kind"], vec![vec![4usize.into(), "qam".into()], vec![8usize.into(), "psk".into()]])?;
assert_eq!(g.conditions()[1].label(), "m=8, kind=psk");
assert!(Grid::new().zip(&["m", "kind"], vec![vec![4usize.into()]]).is_err());Sourcepub fn fixed(self, name: &str, value: impl Into<Value>) -> Grid
pub fn fixed(self, name: &str, value: impl Into<Value>) -> Grid
Add a constant to every condition.
Sourcepub fn check(&self) -> Result<()>
pub fn check(&self) -> Result<()>
Check that every key is given once: by one axis, zip or fixed value, and not by one of them on top of an explicit condition.
§Errors
Error::Config naming the first key given twice.
§Examples
use comnum_sim::grid::{Condition, Grid};
assert!(Grid::new().axis("snr_db", [0.0, 1.0]).fixed("m", 4usize).check().is_ok());
let e = Grid::new().axis("snr_db", [0.0]).axis("snr_db", [1.0]).check().unwrap_err();
assert!(e.to_string().contains("\"snr_db\" twice"));
let cases = Grid::from_conditions(vec![Condition::new().with("m", 4usize)]);
assert!(cases.axis("m", [16usize]).check().is_err());Sourcepub fn conditions(&self) -> Vec<Condition>
pub fn conditions(&self) -> Vec<Condition>
The conditions, in order.
Trait Implementations§
impl StructuralPartialEq for Grid
Auto Trait Implementations§
impl Forget for Grid
impl Freeze for Grid
impl RefUnwindSafe for Grid
impl Send for Grid
impl Sync for Grid
impl Unpin for Grid
impl UnsafeUnpin for Grid
impl UnwindSafe for Grid
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