Crates.io | downsample-oxide |
lib.rs | downsample-oxide |
version | 0.1.2 |
source | src |
created_at | 2023-03-22 04:05:52.77082 |
updated_at | 2023-03-22 04:21:55.290581 |
description | Largest Triangle Three Buckets Implementation |
homepage | https://github.com/Billy-Sheppard/downsample-oxide |
repository | https://github.com/Billy-Sheppard/downsample-oxide |
max_upload_size | |
id | 816699 |
size | 13,572 |
From Jerome's Readme:
An implementation of the largest triangle three buckets (lttb) algorithm for time series downsampling as described in Downsampling Time Series for Visual Representation. This is a Rust port of the original Javascript implementation.
This implementation is heavily based and inspired from his original. Some QOL updates and datatype differences, such as using rust_decimal
and offering output types to work generically or with chrono
or time
(both behind features).
use downsample_oxide::*;
use chrono::*;
fn first_day_of_month(month_num: u32) -> DateTime<Utc> {
NaiveDate::from_ymd_opt(2022, month_num, 1)
.unwrap()
.and_time(NaiveTime::default())
.and_local_timezone(Utc)
.unwrap()
}
fn main() {
let dps = Vec::from([
DataPoint::new(first_day_of_month(1), Decimal::from(10)),
DataPoint::new(first_day_of_month(2), Decimal::from(12)),
DataPoint::new(first_day_of_month(3), Decimal::from(8)),
DataPoint::new(first_day_of_month(4), Decimal::from(10)),
DataPoint::new(first_day_of_month(5), Decimal::from(12)),
]);
let output = dps.downsample(3);
}