Struct TimeFunc

Source
pub struct TimeFunc(pub Vec<(DateTime<Utc>, f64)>);
Expand description

A vector of data points that we can use to analyse time series data. Each data point is valid from the previous timestamp until its current timestamp. If it is the first point of data then it is only valid for a total time of 0.

                .B
          |    /\    |
          |   /  \   |
          |  /    \  |
          | /      \ |
         A./        \.C
__________|__________|_________
Invalid   |  Valid   |  Invalid
_______________________________
          .     .    .
          A     B    C

Tuple Fields§

§0: Vec<(DateTime<Utc>, f64)>

Implementations§

Source§

impl TimeFunc

Source

pub fn new() -> Self

Creates an empty TimeFunc

Source

pub fn get_moving_average(&self, time: DateTime<Utc>, duration: Duration) -> f64

Gets the average of the function from time, to time - duration This function isn’t perfects acurate as it uses the closest available indeces, and does not interpolate

Source

pub fn get_integral_interpolated( &self, time: DateTime<Utc>, duration: Duration, ) -> f64

Gets the average of the function from time, to time - duration This function interpolates the function and uses exact positions

Source

pub fn get_average_interpolated( &self, time: DateTime<Utc>, duration: Duration, ) -> f64

Gets the linear interpolated average of the function

Source

pub fn get_rms(&self, duration: Duration, time: DateTime<Utc>) -> f64

Get’s the normalized RMS Does not use interpolation as of yet

Source

pub fn get_rms_timefunc(&self, duration: Duration) -> Self

Source

pub fn get_inflation(&self, duration: Duration, time: DateTime<Utc>) -> f64

Source

pub fn get_inflation_interpolated( &self, duration: Duration, time: DateTime<Utc>, ) -> f64

Source

pub fn get_inflation_timefunc(&self, duration: Duration) -> Self

Source

pub fn get_inflation_interpolated_timefunc(&self, duration: Duration) -> Self

Source

pub fn get_index(&self, time: &DateTime<Utc>) -> Result<usize, usize>

Source

pub fn get_index_safe(&self, time: &DateTime<Utc>) -> usize

Source

pub fn get_index_above(&self, time: &DateTime<Utc>) -> usize

Source

pub fn get_index_below(&self, time: &DateTime<Utc>) -> usize

Source

pub fn get_fractional_index( &self, time: &DateTime<Utc>, ) -> Result<f64, Box<dyn Error>>

Returns the fractional index of a specific time

Source

pub fn get_value(&self, time: DateTime<Utc>) -> f64

Source

pub fn get_value_interpolated(&self, time: &DateTime<Utc>) -> f64

Source

pub fn push( &mut self, point: (DateTime<Utc>, f64), ) -> Result<(), Box<dyn Error>>

Source

pub fn verify(&self) -> Result<(), Box<dyn Error>>

Verifies that the timefunc is valid. Checks to ensure the list is sorted and deduped.

Source

pub fn dedup(&mut self)

Executed dedup Assumes vec is sorted.

Source

pub fn is_deduped(&self) -> bool

Verifies that the function is deduped Assumes vec is sorted is sorted.

Source

pub fn repair(&mut self)

Fixes the TimeFunc by sorting it.

Source

pub fn draw(&self, title: String) -> Result<(), Box<dyn Error>>

Trait Implementations§

Source§

impl Add for TimeFunc

Source§

type Output = TimeFunc

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Self) -> Self::Output

Performs the + operation. Read more
Source§

impl Clone for TimeFunc

Source§

fn clone(&self) -> TimeFunc

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for TimeFunc

Source§

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

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

impl Default for TimeFunc

Source§

fn default() -> TimeFunc

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for TimeFunc

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 Div for TimeFunc

Source§

type Output = TimeFunc

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Self) -> Self::Output

Performs the / operation. Read more
Source§

impl From<Vec<(DateTime<Utc>, f64)>> for TimeFunc

Source§

fn from(input: Vec<(DateTime<Utc>, f64)>) -> Self

Converts to this type from the input type.
Source§

impl Mul for TimeFunc

Source§

type Output = TimeFunc

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Self) -> Self::Output

Performs the * operation. Read more
Source§

impl Serialize for TimeFunc

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
Source§

impl Sub for TimeFunc

Source§

type Output = TimeFunc

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Self) -> Self::Output

Performs the - operation. 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> 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.
Source§

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