1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/// Calculates the first discrete difference of the input series. For each point, computes the difference between
/// the current value and the previous value (current - previous). The first point in the input series is omitted
/// from the output since it has no previous point to compare against.
///
/// This is equivalent to pandas DataFrame.diff() with period=1. Useful for analyzing changes between consecutive
/// data points in time series data, such as detecting value increases or decreases.
///
/// Example: For input values [1.0, 1.0, 2.0, 2.5, 1.8], the output would be [0.0, 1.0, 0.5, -0.7] at the
/// corresponding timestamps (the first timestamp is omitted).
#[derive(
Debug,
Clone,
conjure_object::serde::Serialize,
conjure_object::serde::Deserialize,
conjure_object::private::DeriveWith
)]
#[serde(crate = "conjure_object::serde")]
#[derive_with(PartialEq, Eq, PartialOrd, Ord, Hash)]
#[conjure_object::private::staged_builder::staged_builder]
#[builder(crate = conjure_object::private::staged_builder, update, inline)]
pub struct ValueDifferenceSeries {
#[builder(custom(type = super::NumericSeries, convert = Box::new))]
#[serde(rename = "input")]
input: Box<super::NumericSeries>,
#[builder(
default,
custom(
type = impl
Into<Option<super::NegativeValueConfiguration>>,
convert = |v|v.into().map(Box::new)
)
)]
#[serde(
rename = "negativeValuesConfiguration",
skip_serializing_if = "Option::is_none",
default
)]
negative_values_configuration: Option<Box<super::NegativeValueConfiguration>>,
}
impl ValueDifferenceSeries {
/// Constructs a new instance of the type.
#[inline]
pub fn new(input: super::NumericSeries) -> Self {
Self::builder().input(input).build()
}
#[inline]
pub fn input(&self) -> &super::NumericSeries {
&*self.input
}
/// Defines the strategy for handling negative output values. Defaults to allowNegativeValues if not specified.
#[inline]
pub fn negative_values_configuration(
&self,
) -> Option<&super::NegativeValueConfiguration> {
self.negative_values_configuration.as_ref().map(|o| &**o)
}
}