pub enum Observation {
Flat(Vec<f32>),
Dict(Vec<(String, Vec<f32>)>),
}Expand description
A concrete observation value.
Flat is the default: a single dense vector of f32 values.
Dict supports multi-modal observations (e.g. image + proprioception),
stored as ordered key-value pairs of named sub-vectors.
Variants§
Flat(Vec<f32>)
A flat float vector (the common case).
Dict(Vec<(String, Vec<f32>)>)
Named sub-observations in a fixed order.
Implementations§
Source§impl Observation
impl Observation
Sourcepub fn flat(data: Vec<f32>) -> Self
pub fn flat(data: Vec<f32>) -> Self
Convenience constructor matching the old tuple-struct API.
Observation::flat(vec) is equivalent to the former Observation(vec).
Sourcepub fn try_as_slice(&self) -> Option<&[f32]>
pub fn try_as_slice(&self) -> Option<&[f32]>
Try to view as a flat f32 slice.
Returns Some(&[f32]) for the Flat variant, None for Dict.
Prefer this over as_slice when handling observations
that may be either variant.
Sourcepub fn as_slice(&self) -> &[f32]
pub fn as_slice(&self) -> &[f32]
View as a flat f32 slice.
For Flat, returns the inner data directly.
§Panics
Panics if the observation is the Dict variant. Use
try_as_slice for a fallible alternative, or
flatten if you need a contiguous copy.
Sourcepub fn into_inner(self) -> Vec<f32>
pub fn into_inner(self) -> Vec<f32>
Consume and return the inner Vec for the Flat variant.
For Dict, returns a flattened (concatenated) copy.
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 PartialEq for Observation
impl PartialEq 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§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>
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>
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