pub struct Observation {
id: ObservationId,
name: String,
annotation: String,
values: Vec<VarValue>,
}
Expand description
A single named observation, i.e., an ordered vector of binarized values.
Fields§
§id: ObservationId
§name: String
§annotation: String
§values: Vec<VarValue>
Implementations§
source§impl Observation
impl Observation
Creating observations.
sourcepub fn new(values: Vec<VarValue>, id: &str) -> Result<Self, String>
pub fn new(values: Vec<VarValue>, id: &str) -> Result<Self, String>
Create Observation
object from a vector of values, and string ID (which must be
a valid identifier).
Name is initialized same as ID, and annotation is empty. For full initializer with name and annotation, check Self::new_annotated.
sourcepub fn new_annotated(
values: Vec<VarValue>,
id: &str,
name: &str,
annot: &str,
) -> Result<Self, String>
pub fn new_annotated( values: Vec<VarValue>, id: &str, name: &str, annot: &str, ) -> Result<Self, String>
Create Observation
object from a vector with values, string ID (which must be
a valid identifier), string name, and annotation.
sourcepub fn new_full_ones(n: usize, id: &str) -> Result<Self, String>
pub fn new_full_ones(n: usize, id: &str) -> Result<Self, String>
Create Observation
encoding a vector of n
ones.
Name is initialized same as ID, and annotation is empty.
sourcepub fn new_full_zeros(n: usize, id: &str) -> Result<Self, String>
pub fn new_full_zeros(n: usize, id: &str) -> Result<Self, String>
Create Observation
encoding a vector of n
zeros.
Name is initialized same as ID, and annotation is empty.
sourcepub fn new_full_unspecified(n: usize, id: &str) -> Result<Self, String>
pub fn new_full_unspecified(n: usize, id: &str) -> Result<Self, String>
Create Observation
encoding a vector of n
unspecified values.
Name is initialized same as ID, and annotation is empty.
sourcepub fn try_from_str(observation_str: &str, id: &str) -> Result<Self, String>
pub fn try_from_str(observation_str: &str, id: &str) -> Result<Self, String>
Create Observation
object from string encoding of its (ordered) values.
Values are encoded using characters 1
, 0
, or *
.
Name is initialized same as ID, and annotation is empty. For full initializer with name and annotation, check Self::try_from_str_annotated.
source§impl Observation
impl Observation
Editing observations.
sourcepub fn set_annotation(&mut self, annotation: &str)
pub fn set_annotation(&mut self, annotation: &str)
Set annotation string.
sourcepub fn set_value(&mut self, index: usize, value: VarValue) -> Result<(), String>
pub fn set_value(&mut self, index: usize, value: VarValue) -> Result<(), String>
Set the value at given idx.
sourcepub fn set_value_by_str(
&mut self,
index: usize,
value: &str,
) -> Result<(), String>
pub fn set_value_by_str( &mut self, index: usize, value: &str, ) -> Result<(), String>
Set the value (one of the “0”/“1”/“*”) at given idx.
sourcepub fn set_all_values(&mut self, values: Vec<VarValue>) -> Result<(), String>
pub fn set_all_values(&mut self, values: Vec<VarValue>) -> Result<(), String>
Set all the values in this observation. The new vector of values must have the same number of values as the original observation (“arity” does not change).
sourcepub fn set_all_values_by_str(&mut self, values: &str) -> Result<(), String>
pub fn set_all_values_by_str(&mut self, values: &str) -> Result<(), String>
Set all the values in this observation via its string encoding (string of “0”/“1”/“*”). The new vector of values must have the same number of values as the original observation (“arity” does not change).
sourcepub fn set_id(&mut self, id: ObservationId)
pub fn set_id(&mut self, id: ObservationId)
Set the id of this observation.
sourcepub fn set_id_by_str(&mut self, id: &str) -> Result<(), String>
pub fn set_id_by_str(&mut self, id: &str) -> Result<(), String>
Set the id of this observation, given the potential ID as string.
source§impl Observation
impl Observation
Observing Observation
instances.
sourcepub fn get_annotation(&self) -> &str
pub fn get_annotation(&self) -> &str
Annotation string of the observation.
sourcepub fn get_values(&self) -> &Vec<VarValue>
pub fn get_values(&self) -> &Vec<VarValue>
Get reference to observation’s vector of values.
sourcepub fn get_id(&self) -> &ObservationId
pub fn get_id(&self) -> &ObservationId
Get reference to observation’s id.
sourcepub fn num_values(&self) -> usize
pub fn num_values(&self) -> usize
Number of all values in this observation (its “length”).
sourcepub fn num_unspecified_values(&self) -> usize
pub fn num_unspecified_values(&self) -> usize
Number of unspecified values in this observation.
sourcepub fn num_specified_values(&self) -> usize
pub fn num_specified_values(&self) -> usize
Number of specified values in this observation.
sourcepub fn to_values_string(&self) -> String
pub fn to_values_string(&self) -> String
Make a string with bit-encoding of values of this Observation
.
Values are encoded using characters 1
, 0
, or *
.
sourcepub fn to_debug_string(&self) -> String
pub fn to_debug_string(&self) -> String
Make a string describing this Observation
in a human-readable format.
The format consists of id and values - id(values)
.
This is mainly for debug purposes, as it is different than classical string serialization.
Trait Implementations§
source§impl Clone for Observation
impl Clone for Observation
source§fn clone(&self) -> Observation
fn clone(&self) -> Observation
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for Observation
impl Debug for Observation
source§impl<'de> Deserialize<'de> for Observation
impl<'de> Deserialize<'de> for Observation
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl PartialEq for Observation
impl PartialEq for Observation
source§impl Serialize for Observation
impl Serialize for Observation
impl Eq for Observation
impl StructuralPartialEq for Observation
Auto Trait Implementations§
impl Freeze for Observation
impl RefUnwindSafe for Observation
impl Send for Observation
impl Sync for Observation
impl Unpin for Observation
impl UnwindSafe for Observation
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<'de, D, R> CommandArg<'de, R> for Dwhere
D: Deserialize<'de>,
R: Runtime,
impl<'de, D, R> CommandArg<'de, R> for Dwhere
D: Deserialize<'de>,
R: Runtime,
§fn from_command(command: CommandItem<'de, R>) -> Result<D, InvokeError>
fn from_command(command: CommandItem<'de, R>) -> Result<D, InvokeError>
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.