Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add rustformat config and CI #1375

Merged
merged 4 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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));
}