Prepare to make external iterator for TimeSeries.
[?]
Jun 11, 2021, 2:55 AM
XIWTRGR6SRVSX3TA6YZVMZIETMZNLJBQSJ3BAL3O6ZXURJPTHQZACDependencies
- [2]
QYLGEDIVFirst record.
Change contents
- edit in src/lib.rs at line 19
use serde::Serializer; - replacement in src/lib.rs at line 26
#[derive(Clone, Copy, Debug, Eq, Serialize)]#[derive(Clone, Copy, Debug, Eq)] - edit in src/lib.rs at line 66
}impl Serialize for MonthlyDate {fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>whereS: Serializer,{serializer.serialize_str(&format!("{}-{:02}-01", self.year(), self.month()))} - edit in src/lib.rs at line 208
impl RegularTimeSeries::<1> { - edit in src/lib.rs at line 211
/// Consume two `RegularTimeSeries<1>` and return a `RegularTimeSeries<2>` over a tuple of the/// original values. If the duration of the two time-series' are different then panic. If the/// the result is empty, return an empty `RegularTimeSeries`.pub fn zip(self, other: RegularTimeSeries<1>) -> RegularTimeSeries<2> {// Each TimeSeries is a Vec of DatePoints. We can therefore just do the checks and use a// consuming iterator over all the DatePoints.if self.duration() != other.duration() { panic!() };// Find first and last dates, then create iterators with this date range and zip.let first_date = self.first_date().max(other.first_date());let last_date = self.last_date().min(other.last_date());let date_range = DateRange::new(Some(first_date), Some(last_date));let v: Vec<DatePoint<2>> = Vec::new();let () = self.iter(date_range);for (dp1, dp2) in self.iter(date_range).zip(other.iter(date_range)) {// let () = dp1;v.push(DatePoint::<2>::new(dp1.date(), [ dp1.value(0), dp2.value(0) ]));}TimeSeries::<2>::new(v).try_into().unwrap()}} - edit in src/lib.rs at line 244
- edit in src/lib.rs at line 324
// Shouldn't we make a external RegularTimeSeriesIter ? It points into RegularTimeSeries and has a flag which// manages the dates. - replacement in src/lib.rs at line 329
/// A range of dates with monthly granularity./// A `DateRange` is used to constrain a `TimeSeries` iterator over a range of dates. If/// `start_date` or `end_date` are `None` then the iterator will start at the first value in the/// `TimeSeries` or end at the last value in the `TimeSeries` respectively. - edit in src/lib.rs at line 339
pub fn new(start_date: Option<MonthlyDate>, end_date: Option<MonthlyDate>) -> Self {DateRange { start_date, end_date }}