Skip to content

Commit 7aeef0f

Browse files
committed
🎉 first pypi deploy
1 parent 1da2940 commit 7aeef0f

File tree

6 files changed

+260
-20
lines changed

6 files changed

+260
-20
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: CI tsdownsample
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
8+
9+
defaults:
10+
run:
11+
shell: bash
12+
13+
jobs:
14+
Check:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v2
19+
20+
- name: Install Rust toolchain
21+
uses: actions-rs/toolchain@v1
22+
with:
23+
profile: minimal
24+
toolchain: nightly
25+
components: clippy, rustfmt
26+
- name: Setup Rust
27+
run: |
28+
rustup update nightly --no-self-update
29+
rustup default nightly
30+
31+
- name: Rust toolchain info
32+
run: |
33+
cargo --version --verbose
34+
rustc --version
35+
cargo clippy --version
36+
cargo fmt --version
37+
38+
- name: check
39+
run: cargo check --verbose
40+
- name: formatting check
41+
run: cargo fmt --all -- --check

README.md

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,51 @@
11
# tsdownsample
2-
Time series downsampling algorithms for visualization
2+
3+
[![PyPI Latest Release](https://img.shields.io/pypi/v/tsdownsample.svg)](https://pypi.org/project/tsdownsample/)
4+
[![support-version](https://img.shields.io/pypi/pyversions/tsdownsample)](https://img.shields.io/pypi/pyversions/tsdownsample)
5+
[![Downloads](https://pepy.tech/badge/tsdownsample)](https://pepy.tech/project/tsdownsample)
6+
<!-- [![Testing](https://github.com/predict-idlab/tsflex/actions/workflows/test.yml/badge.svg)](https://github.com/predict-idlab/tsflex/actions/workflows/test.yml) -->
7+
8+
**📈 Time series downsampling** algorithms for visualization
9+
10+
## Features ✨
11+
12+
* **Fast**: written in rust with pyo3 bindings
13+
- leverages optimized [argminmax](https://github.com/jvdd/argminmax) - which is SIMD accelerated with runtime feature detection
14+
- scales linearly with the number of data points
15+
- scales multi-threaded with rayon (rust)
16+
* **Efficient**: memory efficient
17+
- works on views of the data (no copies)
18+
- no intermediate data structures are created
19+
* **Flexible**: works on any type of data
20+
- supported datatypes are `f16`, `f32`, `f64`, `i16`, `i32`, `i64`, `u16`, `u32`, `u64`
21+
*!! 🚀 `f16` [argminmax](https://github.com/jvdd/argminmax) is 200-300x faster than numpy*
22+
* **Easy to use**: simple API
23+
24+
## Install
25+
26+
> ❗🚨❗ This package is currently under development - no stable release yet ❗🚨❗
27+
28+
29+
```bash
30+
pip install tsdownsample
31+
```
32+
33+
## Usage
34+
35+
```python
36+
import tsdownsample as tsds
37+
import pandas as pd; import numpy as np
38+
39+
# Create a time series
40+
y = np.random.randn(10_000_000)
41+
s = pd.Series(y)
42+
43+
# Downsample to 1000 points
44+
s_ds = tsds.minmaxlttb(s, n_out=1000)
45+
```
46+
47+
---
48+
49+
<p align="center">
50+
👤 <i>Jeroen Van Der Donckt</i>
51+
</p>

poetry.lock

Lines changed: 131 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
[tool.poetry]
2+
name = "tsdownsample"
3+
version = "0.1.0a0"
4+
description = "Time series downsampling in rust"
5+
authors = ["Jeroen Van Der Donckt"]
6+
readme = "README.md"
7+
license = "MIT"
8+
repository = "https://github.com/predict-idlab/tsdownsample"
9+
keywords = ["time series", "downsampling", "rust", "data science", "visualization"]
10+
11+
[tool.poetry.dependencies]
12+
python = "^3.7.1"
13+
numpy = ">=1.21"
14+
pandas = ">=1.3"
15+
16+
[tool.poetry.dev-dependencies]
17+
18+
[build-system]
19+
requires = ["poetry-core>=1.0.0"]
20+
build-backend = "poetry.core.masonry.api"

src/lib.rs

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
extern crate downsample_rs;
22
extern crate paste;
33

4-
54
// TODO
65
// - support bool
76
// => issue: does not have to_primitive (necessary for lttb)
@@ -39,30 +38,29 @@ macro_rules! _create_pyfunc_without_x {
3938
}
4039
// Add the function to the module
4140
$mod.add_wrapped(wrap_pyfunction!($name))?;
42-
};
43-
// ($name:ident, $resample_mod:ident, $resample_fn:ident, $type:ty, $mod:ident, $cast_type:ty) => {
44-
// // Create the Python function
45-
// #[pyfunction]
46-
// fn $name<'py>(
47-
// py: Python<'py>,
48-
// y: PyReadonlyArray1<$type>,
49-
// n_out: usize,
50-
// ) -> &'py PyArray1<usize> {
51-
// let y = y.as_array().mapv(|v| v as $cast_type);
52-
// let sampled_indices = $resample_mod::$resample_fn(y.view(), n_out);
53-
// sampled_indices.into_pyarray(py)
54-
// }
55-
// // Add the function to the module
56-
// $mod.add_wrapped(wrap_pyfunction!($name))?;
57-
// };
41+
}; // ($name:ident, $resample_mod:ident, $resample_fn:ident, $type:ty, $mod:ident, $cast_type:ty) => {
42+
// // Create the Python function
43+
// #[pyfunction]
44+
// fn $name<'py>(
45+
// py: Python<'py>,
46+
// y: PyReadonlyArray1<$type>,
47+
// n_out: usize,
48+
// ) -> &'py PyArray1<usize> {
49+
// let y = y.as_array().mapv(|v| v as $cast_type);
50+
// let sampled_indices = $resample_mod::$resample_fn(y.view(), n_out);
51+
// sampled_indices.into_pyarray(py)
52+
// }
53+
// // Add the function to the module
54+
// $mod.add_wrapped(wrap_pyfunction!($name))?;
55+
// };
5856
}
5957

6058
macro_rules! _create_pyfuncs_without_x {
6159
($resample_mod:ident, $resample_fn:ident, $mod:ident, $($t:ty)*) => {
6260
$(
6361
paste! {
6462
_create_pyfunc_without_x!([<downsample_ $t>], $resample_mod, $resample_fn, $t, $mod);
65-
}
63+
}
6664
)*
6765
};
6866
}
@@ -99,7 +97,7 @@ macro_rules! _create_pyfuncs_with_x {
9997
$(
10098
paste! {
10199
_create_pyfunc_with_x!([<downsample_ $tx _ $ty>], $resample_mod, $resample_fn, $tx, $ty, $mod);
102-
}
100+
}
103101
)*
104102
};
105103
}

tsdownsample/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import tsdownample_rs as _tsdownsample_rs

0 commit comments

Comments
 (0)