diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d7942c8..3dd3361 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,14 +19,13 @@ jobs: { os: "ubuntu", target: "i686-unknown-linux-gnu" }, { os: "ubuntu", target: "wasm32-unknown-unknown" }, { os: "macos", target: "aarch64-apple-darwin" }, - { os: "ubuntu", target: "wasm32-wasi" }, ] env: TZ: "/usr/share/zoneinfo/your/location" steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Cache .cargo and target - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: | ~/.cargo @@ -36,16 +35,13 @@ jobs: - name: Install Rust toolchain uses: actions-rs/toolchain@v1 with: - toolchain: 1.81 # 1.82 seems to break wasm32 tests https://github.com/rustwasm/wasm-bindgen/issues/4274 + toolchain: stable target: ${{ matrix.platform.target }} profile: minimal default: true - name: Install test runner for wasm if: matrix.platform.target == 'wasm32-unknown-unknown' run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh - - name: Install test runner for wasi - if: matrix.platform.target == 'wasm32-wasi' - run: curl https://wasmtime.dev/install.sh -sSf | bash - name: Stable Build with all features uses: actions-rs/cargo@v1 with: @@ -65,13 +61,7 @@ jobs: - name: Tests in WASM if: matrix.platform.target == 'wasm32-unknown-unknown' run: wasm-pack test --node -- --all-features - - name: Tests in WASI - if: matrix.platform.target == 'wasm32-wasi' - run: | - export WASMTIME_HOME="$HOME/.wasmtime" - export PATH="$WASMTIME_HOME/bin:$PATH" - cargo install cargo-wasi && cargo wasi test - + check_features: runs-on: "${{ matrix.platform.os }}-latest" strategy: @@ -81,9 +71,9 @@ jobs: env: TZ: "/usr/share/zoneinfo/your/location" steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Cache .cargo and target - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: | ~/.cargo diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 4dc07d7..01768b3 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -12,9 +12,9 @@ jobs: env: TZ: "/usr/share/zoneinfo/your/location" steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Cache .cargo - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: | ~/.cargo diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 77a082f..8c7fd08 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -14,7 +14,7 @@ jobs: steps: - uses: actions/checkout@v2 - name: Cache .cargo and target - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: | ~/.cargo diff --git a/Cargo.toml b/Cargo.toml index b2e186a..6ce1952 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ name = "smartcore" description = "Machine Learning in Rust." homepage = "https://smartcorelib.org" -version = "0.4.0" +version = "0.4.1" authors = ["smartcore Developers"] edition = "2021" license = "Apache-2.0" diff --git a/src/linalg/basic/matrix.rs b/src/linalg/basic/matrix.rs index 88a0849..1a4ae4d 100644 --- a/src/linalg/basic/matrix.rs +++ b/src/linalg/basic/matrix.rs @@ -663,6 +663,7 @@ mod tests { #[test] fn test_instantiate_err_view3() { let x = DenseMatrix::from_2d_array(&[&[1., 2., 3.], &[4., 5., 6.], &[7., 8., 9.]]).unwrap(); + #[allow(clippy::reversed_empty_ranges)] let v = DenseMatrixView::new(&x, 0..3, 4..3); assert!(v.is_err()); } diff --git a/src/naive_bayes/bernoulli.rs b/src/naive_bayes/bernoulli.rs index 4be62d5..cdd5b83 100644 --- a/src/naive_bayes/bernoulli.rs +++ b/src/naive_bayes/bernoulli.rs @@ -257,8 +257,7 @@ impl BernoulliNBDistribution { /// Fits the distribution to a NxM matrix where N is number of samples and M is number of features. /// * `x` - training data. /// * `y` - vector with target values (classes) of length N. - /// * `priors` - Optional vector with prior probabilities of the classes. If not defined, - /// priors are adjusted according to the data. + /// * `priors` - Optional vector with prior probabilities of the classes. If not defined, priors are adjusted according to the data. /// * `alpha` - Additive (Laplace/Lidstone) smoothing parameter. /// * `binarize` - Threshold for binarizing. fn fit, Y: Array1>( diff --git a/src/naive_bayes/gaussian.rs b/src/naive_bayes/gaussian.rs index e774fdc..dbf3fd8 100644 --- a/src/naive_bayes/gaussian.rs +++ b/src/naive_bayes/gaussian.rs @@ -174,8 +174,7 @@ impl GaussianNBDistribution { /// Fits the distribution to a NxM matrix where N is number of samples and M is number of features. /// * `x` - training data. /// * `y` - vector with target values (classes) of length N. - /// * `priors` - Optional vector with prior probabilities of the classes. If not defined, - /// priors are adjusted according to the data. + /// * `priors` - Optional vector with prior probabilities of the classes. If not defined, priors are adjusted according to the data. pub fn fit, Y: Array1>( x: &X, y: &Y, diff --git a/src/naive_bayes/multinomial.rs b/src/naive_bayes/multinomial.rs index e00965e..ad87394 100644 --- a/src/naive_bayes/multinomial.rs +++ b/src/naive_bayes/multinomial.rs @@ -207,8 +207,7 @@ impl MultinomialNBDistribution { /// Fits the distribution to a NxM matrix where N is number of samples and M is number of features. /// * `x` - training data. /// * `y` - vector with target values (classes) of length N. - /// * `priors` - Optional vector with prior probabilities of the classes. If not defined, - /// priors are adjusted according to the data. + /// * `priors` - Optional vector with prior probabilities of the classes. If not defined, priors are adjusted according to the data. /// * `alpha` - Additive (Laplace/Lidstone) smoothing parameter. pub fn fit, Y: Array1>( x: &X, diff --git a/src/preprocessing/categorical.rs b/src/preprocessing/categorical.rs index e17dea7..7079460 100644 --- a/src/preprocessing/categorical.rs +++ b/src/preprocessing/categorical.rs @@ -24,7 +24,7 @@ //! // &[1.5, 1.0, 0.0, 1.5, 0.0, 0.0, 1.0, 0.0] //! // &[1.5, 0.0, 1.0, 1.5, 0.0, 0.0, 0.0, 1.0] //! ``` -use std::iter; +use std::iter::repeat_n; use crate::error::Failed; use crate::linalg::basic::arrays::Array2; @@ -75,11 +75,7 @@ fn find_new_idxs(num_params: usize, cat_sizes: &[usize], cat_idxs: &[usize]) -> let offset = (0..1).chain(offset_); let new_param_idxs: Vec = (0..num_params) - .zip( - repeats - .zip(offset) - .flat_map(|(r, o)| iter::repeat(o).take(r)), - ) + .zip(repeats.zip(offset).flat_map(|(r, o)| repeat_n(o, r))) .map(|(idx, ofst)| idx + ofst) .collect(); new_param_idxs @@ -124,7 +120,7 @@ impl OneHotEncoder { let (nrows, _) = data.shape(); // col buffer to avoid allocations - let mut col_buf: Vec = iter::repeat(T::zero()).take(nrows).collect(); + let mut col_buf: Vec = repeat_n(T::zero(), nrows).collect(); let mut res: Vec> = Vec::with_capacity(idxs.len());