Added in-place mut_range() and range().
[?]
CrEcTsRjb1hHQjHuumqRfqdbVV4X58iLEubi4noaDPFa
Jul 23, 2021, 5:16 AM
NLFSLCBOGCQYI2DQXLO5AWBBRABDS26NIX6HGUGO2KQG2OHQGWOQCDependencies
- [2]
VGDNIY33Added error source locations. - [3]
IYW574EKCreated RegularTimeSeriesIter. - [4]
TD7KX2PIAdded year-on-year transform. - [5]
XIWTRGR6Prepare to make external iterator for TimeSeries. - [6]
QYLGEDIVFirst record. - [7]
YMV7RPQ5Improved csv reading and cleanup up serialization. - [8]
XCCNAGMZCreated with_range() fn on RegularTimeSeries.
Change contents
- replacement in src/lib.rs at line 24
/// A duration between two `MonthlyDates`. The value can be positive or negative./// A duration between two `MonthlyDates`.////// The value can be positive or negative. - replacement in src/lib.rs at line 53
/// A date with granularity of one month or larger. Dates can also act as durations and be added/// and subtracted./// A date with monthly granularity or larger. - replacement in src/lib.rs at line 55
/// To avoid pulling in redundant dependences, the responsibility for parsing a date in string form/// is left to the client code./// Client code is responsible for parsing strings into `MonthlyDate`s. - replacement in src/lib.rs at line 133
/// A date of monthly granularity associated with a numeric array of data./// A `MonthlyDate` associated with some data. - replacement in src/lib.rs at line 157
/// `TimeSeries` is a collection of `DatePoints`. There are no guarantees of ordering./// A time-series with no guarantees of ordering. - replacement in src/lib.rs at line 177
.map_err(|_| failed_to_read_file(file!(), line!(), &path))?;.map_err(|_| read_file_error(file!(), line!(), &path))?; - replacement in src/lib.rs at line 185
return Err(failed_to_parse_csv_date(return Err(parse_csv_date_failed( - replacement in src/lib.rs at line 198
return Err(failed_to_parse_csv_date(return Err(parse_csv_date_failed( - replacement in src/lib.rs at line 211
return Err(failed_to_parse_csv_value(return Err(parse_csv_value_failed( - replacement in src/lib.rs at line 344
/// A `RegularTimeSeries` has an additional requirements over `TimeSeries` in the time interval/// between successive `DatePoints` has the same `Duration`. This also ensures ordering. A/// `RegularTimeSeries` is guaranteed to have two or more data points./// A time-series with regular, contiguous data.////// A `RegularTimeSeries` is guaranteed to have two or more data points. - edit in src/lib.rs at line 394
// Constrain a `RegularTimeSeries` in-place with a new date range. - replacement in src/lib.rs at line 398
pub fn with_range(&mut self, date_range: &DateRange) {pub fn mut_range(&mut self, date_range: &DateRange) { - edit in src/lib.rs at line 408
}}// Return a new `RegularTimeSeries` with a new date range.impl<const N: usize> RegularTimeSeries<N> {/// Remove `DatePoints` outside `date_range` from `Self`.pub fn range(&self, date_range: &DateRange) -> RegularTimeSeries<N> {let start_date = match date_range.start_date {None => self.ts.0.first().unwrap().date(),Some(start) => start,};let end_date = match date_range.end_date {None => self.ts.0.last().unwrap().date(),Some(end) => end,};let mut ts = TimeSeries::new(Vec::new());for dp in self.ts.0.iter() {if dp.date() >= start_date && dp.date() <= end_date {ts.0.push(*dp)};}ts.try_into().unwrap() - replacement in src/lib.rs at line 620
/// 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.#[derive(Clone, Copy, Debug)]/// Specifies the time-span of the data.#[derive(Clone, Copy, Debug, Serialize)] - replacement in src/error.rs at line 38
"[time_series:01:{}:{}] Expected positive duration between {} and {}.","[time_series:02:{}:{}] Expected positive duration between {} and {}.", - replacement in src/error.rs at line 49
"[time_series:01] Expected regular time-series.""[time_series:03] Expected regular time-series." - replacement in src/error.rs at line 54
pub fn failed_to_parse_csv_date(pub fn parse_csv_date_failed( - replacement in src/error.rs at line 62
"[time_series:02:{}:{}] Line: {} file: {}, . Failed to parse date on line [{}].","[time_series:04:{}:{}] Line {} file {}. Failed to parse date on line [{}].", - replacement in src/error.rs at line 72
pub fn failed_to_parse_csv_value(pub fn parse_csv_value_failed( - replacement in src/error.rs at line 80
"[time_series:03:{}:{}] Line: {} file: {}. Failed to parse value on line [{}].","[time_series:05:{}:{}] Line {} file {}. Failed to parse value on line [{}].", - replacement in src/error.rs at line 89
pub fn failed_to_read_file(pub fn read_file_error( - replacement in src/error.rs at line 95
"[time_series:05:{}:{}] Failed to read file [{}].","[time_series:06:{}:{}] Failed to read file [{}].", - edit in src/error.rs at line 101
- replacement in src/error.rs at line 108
"[time_series:04:{}:{}] Time-series has only one point.","[time_series:07:{}:{}] Time-series has only one point.", - replacement in src/error.rs at line 120
"[time_series:05:{}:{}] Time-series is empty.","[time_series:08:{}:{}] Time-series is empty.",