diff --git a/.github/workflows/ci-tsdownsample.yml b/.github/workflows/ci-tsdownsample.yml index c56804f..4d741f9 100644 --- a/.github/workflows/ci-tsdownsample.yml +++ b/.github/workflows/ci-tsdownsample.yml @@ -87,7 +87,7 @@ jobs: # Perhaps smth more in line with this https://github.com/messense/crfs-rs/blob/main/.github/workflows/Python.yml name: build on ${{ matrix.os }} (${{ matrix.target }} - ${{ matrix.manylinux || 'auto' }}) # only run on push to main and on release - if: "success() && (startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main' || contains(github.event.pull_request.labels.*.name, 'Full Build'))" + # if: "success() && (startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main' || contains(github.event.pull_request.labels.*.name, 'Full Build'))" strategy: fail-fast: false matrix: @@ -166,7 +166,7 @@ jobs: Release: needs: [Lint_and_Check, Test, Build] - if: "success() && startsWith(github.ref, 'refs/tags/')" + # if: "success() && startsWith(github.ref, 'refs/tags/')" runs-on: ubuntu-latest steps: diff --git a/Cargo.toml b/Cargo.toml index abac645..5f3bbbd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,8 +11,8 @@ license = "MIT" downsample_rs = { path = "downsample_rs", features = ["half"]} pyo3 = { version = "0.26", features = ["extension-module"] } numpy = { version = "0.26", features = ["half"] } -half = { version = "2.3.1", default-features = false } -paste = { version = "1.0.14", default-features = false } +half = { version = "2.6", default-features = false } +paste = { version = "1.0", default-features = false } [lib] name = "tsdownsample" diff --git a/downsample_rs/Cargo.toml b/downsample_rs/Cargo.toml index 107469b..2702b84 100644 --- a/downsample_rs/Cargo.toml +++ b/downsample_rs/Cargo.toml @@ -8,16 +8,16 @@ license = "MIT" [dependencies] # TODO: perhaps use polars? -argminmax = { version = "0.6.1", features = ["half"] } -half = { version = "2.3.1", default-features = false , features=["num-traits"], optional = true} -num-traits = { version = "0.2.17", default-features = false } +argminmax = { version = "0.6", features = ["half"] } +half = { version = "2.7", default-features = false , features=["num-traits"], optional = true} +num-traits = { version = "0.2", default-features = false } once_cell = "1" -rayon = { version = "1.8.0", default-features = false } +rayon = { version = "1", default-features = false } [dev-dependencies] -rstest = { version = "0.18.2", default-features = false } -rstest_reuse = { version = "0.6", default-features = false } -criterion = "0.5.1" +rstest = { version = "0.26", default-features = false } +rstest_reuse = { version = "0.7", default-features = false } +criterion = "0.7" dev_utils = { path = "dev_utils" } [[bench]] diff --git a/downsample_rs/dev_utils/Cargo.toml b/downsample_rs/dev_utils/Cargo.toml index 2ab2e6b..ab07e26 100644 --- a/downsample_rs/dev_utils/Cargo.toml +++ b/downsample_rs/dev_utils/Cargo.toml @@ -6,5 +6,6 @@ edition = "2021" description = "Shared utilities for development (tests & benchmarks)" [dependencies] -rand = { version = "0.7.2", default-features = false } -rand_distr = { version = "0.2.2", default-features = false } +num-traits = { version = "0.2", default-features = false } +half = { version = "2.7", default-features = false, features = ["num-traits", "rand_distr"] } +rand = { version = "0.9", default-features = false } diff --git a/downsample_rs/dev_utils/src/utils.rs b/downsample_rs/dev_utils/src/utils.rs index 975fa65..a920a54 100644 --- a/downsample_rs/dev_utils/src/utils.rs +++ b/downsample_rs/dev_utils/src/utils.rs @@ -1,17 +1,33 @@ use std::ops::{Add, Sub}; -use rand::{thread_rng, Rng}; -use rand_distr::Uniform; +use num_traits::{NumCast, ToPrimitive}; +use rand::distr::uniform::Error as UniformError; +use rand::distr::Uniform; +use rand::{rng, Rng}; // random array that samples between min and max of T pub fn get_random_array(n: usize, min_value: T, max_value: T) -> Vec where - T: Copy + rand::distributions::uniform::SampleUniform, + T: Copy + rand::distr::uniform::SampleUniform + ToPrimitive + NumCast, { - let rng = thread_rng(); - let uni = Uniform::new_inclusive(min_value, max_value); - let arr: Vec = rng.sample_iter(uni).take(n).collect(); - arr + let rng = rng(); + match Uniform::new_inclusive(min_value, max_value) { + Ok(uni) => rng.sample_iter(uni).take(n).collect(), + Err(UniformError::NonFinite) => { + let min = min_value + .to_f64() + .expect("failed to convert lower bound to f64"); + let max = max_value + .to_f64() + .expect("failed to convert upper bound to f64"); + let uni = Uniform::new_inclusive(min, max).unwrap(); + rng.sample_iter(uni) + .take(n) + .map(|v| NumCast::from(v).expect("failed to convert sample")) + .collect() + } + Err(err) => panic!("invalid range for random array: {err:?}"), + } } // worst case array that alternates between increasing max and decreasing min values diff --git a/pyproject.toml b/pyproject.toml index 59e10fa..ddf17a6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ build-backend = "maturin" [project] name = "tsdownsample" description = "Time series downsampling in rust" -version = "0.1.4.1" +version = "0.1.5" requires-python = ">=3.8" dependencies = ["numpy"] authors = [{name = "Jeroen Van Der Donckt"}] diff --git a/tsdownsample/__init__.py b/tsdownsample/__init__.py index bfed60a..0725db3 100644 --- a/tsdownsample/__init__.py +++ b/tsdownsample/__init__.py @@ -11,7 +11,7 @@ NaNMinMaxLTTBDownsampler, ) -__version__ = "0.1.4.1" +__version__ = "0.1.5" __author__ = "Jeroen Van Der Donckt" __all__ = [