Skip to content

Commit

Permalink
Merge pull request #1375 from rust-ndarray/rustfmt2
Browse files Browse the repository at this point in the history
Add rustformat config and CI
  • Loading branch information
bluss authored Mar 13, 2024
2 parents 5465bc4 + d07f5f3 commit b417e93
Show file tree
Hide file tree
Showing 138 changed files with 5,042 additions and 3,834 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,22 @@ jobs:
components: clippy
- uses: Swatinem/rust-cache@v2
- run: cargo clippy --features docs

format:
runs-on: ubuntu-latest
strategy:
matrix:
rust:
- nightly
name: format/${{ matrix.rust }}
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}
components: rustfmt
- run: cargo fmt --all --check

tests:
runs-on: ubuntu-latest
strategy:
Expand Down Expand Up @@ -103,6 +119,7 @@ jobs:
conclusion:
needs:
- clippy
# - format # should format be required?
- tests
- cross_test
- cargo-careful
Expand Down
21 changes: 9 additions & 12 deletions benches/append.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,27 @@ use test::Bencher;
use ndarray::prelude::*;

#[bench]
fn select_axis0(bench: &mut Bencher) {
fn select_axis0(bench: &mut Bencher)
{
let a = Array::<f32, _>::zeros((256, 256));
let selectable = vec![0, 1, 2, 0, 1, 3, 0, 4, 16, 32, 128, 147, 149, 220, 221, 255, 221, 0, 1];
bench.iter(|| {
a.select(Axis(0), &selectable)
});
bench.iter(|| a.select(Axis(0), &selectable));
}

#[bench]
fn select_axis1(bench: &mut Bencher) {
fn select_axis1(bench: &mut Bencher)
{
let a = Array::<f32, _>::zeros((256, 256));
let selectable = vec![0, 1, 2, 0, 1, 3, 0, 4, 16, 32, 128, 147, 149, 220, 221, 255, 221, 0, 1];
bench.iter(|| {
a.select(Axis(1), &selectable)
});
bench.iter(|| a.select(Axis(1), &selectable));
}

#[bench]
fn select_1d(bench: &mut Bencher) {
fn select_1d(bench: &mut Bencher)
{
let a = Array::<f32, _>::zeros(1024);
let mut selectable = (0..a.len()).step_by(17).collect::<Vec<_>>();
selectable.extend(selectable.clone().iter().rev());

bench.iter(|| {
a.select(Axis(0), &selectable)
});
bench.iter(|| a.select(Axis(0), &selectable));
}
Loading

0 comments on commit b417e93

Please sign in to comment.