Skip to content

Try to make the master branch shipshape #1286

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

Merged
merged 5 commits into from
May 24, 2023
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 11 additions & 20 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,11 @@ jobs:
- 1.51.0 # MSRV

steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@master
with:
profile: minimal
toolchain: ${{ matrix.rust }}
override: true
- uses: Swatinem/rust-cache@v2
- name: Install openblas
run: sudo apt-get install libopenblas-dev gfortran
- run: ./scripts/all-tests.sh "$FEATURES" ${{ matrix.rust }}
Expand All @@ -45,20 +44,14 @@ jobs:
target: i686-unknown-linux-gnu

steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@master
with:
profile: minimal
toolchain: ${{ matrix.rust }}
target: ${{ matrix.target }}
override: true
- name: Cache cargo plugins
uses: actions/cache@v1
with:
path: ~/.cargo/bin/
key: ${{ runner.os }}-cargo-plugins
targets: ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
- name: Install cross
run: cargo install cross || true
run: cargo install cross
- run: ./scripts/cross-tests.sh "docs" ${{ matrix.rust }} ${{ matrix.target }}

clippy:
Expand All @@ -68,12 +61,10 @@ jobs:
rust:
- beta
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@master
with:
profile: minimal
toolchain: ${{ matrix.rust }}
override: true
components: clippy
- uses: Swatinem/rust-cache@v2
- run: cargo clippy --features docs

8 changes: 5 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,15 @@ rayon = ["rayon_", "std"]

matrixmultiply-threading = ["matrixmultiply/threading"]

[profile.release]
[profile.bench]
debug = true
[profile.dev.package.numeric-tests]
opt-level = 2
[profile.test.package.numeric-tests]
opt-level = 2

[workspace]
members = ["ndarray-rand", "xtest-serialization", "xtest-blas"]
exclude = ["xtest-numeric"]
members = ["ndarray-rand", "xtest-serialization", "xtest-blas", "xtest-numeric"]

[package.metadata.release]
no-dev-version = true
Expand Down
14 changes: 12 additions & 2 deletions scripts/all-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ set -e
FEATURES=$1
CHANNEL=$2

if [ "$CHANNEL" = "1.51.0" ]; then
cargo update --package rayon --precise 1.5.3
cargo update --package rayon-core --precise 1.9.3
cargo update --package serde --precise 1.0.156
cargo update --package thiserror --precise 1.0.39
cargo update --package once_cell --precise 1.14.0
cargo update --package openblas-src --precise 0.10.5
cargo update --package openblas-build --precise 0.10.5
fi

cargo build --verbose --no-default-features
# Testing both dev and release profiles helps find bugs, especially in low level code
cargo test --verbose --no-default-features
Expand All @@ -17,6 +27,6 @@ cargo test --manifest-path=ndarray-rand/Cargo.toml --features quickcheck --verbo
cargo test --manifest-path=xtest-serialization/Cargo.toml --verbose
cargo test --manifest-path=xtest-blas/Cargo.toml --verbose --features openblas-system
cargo test --examples
CARGO_TARGET_DIR=target/ cargo test --manifest-path=xtest-numeric/Cargo.toml --verbose
CARGO_TARGET_DIR=target/ cargo test --manifest-path=xtest-numeric/Cargo.toml --verbose --features test_blas
cargo test --manifest-path=xtest-numeric/Cargo.toml --verbose
cargo test --manifest-path=xtest-numeric/Cargo.toml --verbose --features test_blas
([ "$CHANNEL" != "nightly" ] || cargo bench --no-run --verbose --features "$FEATURES")
2 changes: 1 addition & 1 deletion scripts/cross-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ cross build -v --features="$FEATURES" --target=$TARGET
cross test -v --no-fail-fast --features="$FEATURES" --target=$TARGET
cross test -v --no-fail-fast --target=$TARGET --manifest-path=ndarray-rand/Cargo.toml --features quickcheck
cross test -v --no-fail-fast --target=$TARGET --manifest-path=xtest-serialization/Cargo.toml --verbose
CARGO_TARGET_DIR=target/ cross test -v --no-fail-fast --target=$TARGET --manifest-path=xtest-numeric/Cargo.toml
cross test -v --no-fail-fast --target=$TARGET --manifest-path=xtest-numeric/Cargo.toml
2 changes: 1 addition & 1 deletion src/arraytraits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ where
{
}

#[cfg(any(feature = "serde"))]
#[cfg(feature = "serde")]
// Use version number so we can add a packed format later.
pub const ARRAY_FORMAT_VERSION: u8 = 1u8;

Expand Down
6 changes: 3 additions & 3 deletions src/dimension/dimension_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ pub trait Dimension:

/// Compute the size of the dimension (number of elements)
fn size(&self) -> usize {
self.slice().iter().fold(1, |s, &a| s * a as usize)
self.slice().iter().product()
}

/// Compute the size while checking for overflow.
Expand Down Expand Up @@ -603,7 +603,7 @@ impl Dimension for Dim<[Ix; 2]> {
fn size_checked(&self) -> Option<usize> {
let m = get!(self, 0);
let n = get!(self, 1);
(m as usize).checked_mul(n as usize)
m.checked_mul(n)
}

#[inline]
Expand Down Expand Up @@ -728,7 +728,7 @@ impl Dimension for Dim<[Ix; 3]> {
let m = get!(self, 0);
let n = get!(self, 1);
let o = get!(self, 2);
m as usize * n as usize * o as usize
m * n * o
}

#[inline]
Expand Down
2 changes: 1 addition & 1 deletion src/dimension/dynindeximpl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ impl<T: PartialEq> PartialEq for IxDynRepr<T> {
match (self, rhs) {
(&IxDynRepr::Inline(slen, ref sarr), &IxDynRepr::Inline(rlen, ref rarr)) => {
slen == rlen
&& (0..CAP as usize)
&& (0..CAP)
.filter(|&i| i < slen as usize)
.all(|i| sarr[i] == rarr[i])
}
Expand Down
2 changes: 1 addition & 1 deletion src/dimension/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ mod sequence;
/// Calculate offset from `Ix` stride converting sign properly
#[inline(always)]
pub fn stride_offset(n: Ix, stride: Ix) -> isize {
(n as isize) * ((stride as Ixs) as isize)
(n as isize) * (stride as Ixs)
}

/// Check whether the given `dim` and `stride` lead to overlapping indices
Expand Down
2 changes: 1 addition & 1 deletion src/impl_methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1990,7 +1990,7 @@ where
let strides = unlimited_transmute::<D, D2>(self.strides);
return Ok(ArrayBase::from_data_ptr(self.data, self.ptr)
.with_strides_dim(strides, dim));
} else if D::NDIM == None || D2::NDIM == None { // one is dynamic dim
} else if D::NDIM.is_none() || D2::NDIM.is_none() { // one is dynamic dim
// safe because dim, strides are equivalent under a different type
if let Some(dim) = D2::from_dimension(&self.dim) {
if let Some(strides) = D2::from_dimension(&self.strides) {
Expand Down
4 changes: 2 additions & 2 deletions src/indexes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ where
.slice()
.iter()
.zip(ix.slice().iter())
.fold(0, |s, (&a, &b)| s + a as usize * b as usize);
.fold(0, |s, (&a, &b)| s + a * b);
self.dim.size() - gone
}
};
Expand Down Expand Up @@ -286,7 +286,7 @@ where
.slice()
.iter()
.zip(self.index.slice().iter())
.fold(0, |s, (&a, &b)| s + a as usize * b as usize);
.fold(0, |s, (&a, &b)| s + a * b);
let l = self.dim.size() - gone;
(l, Some(l))
}
Expand Down
2 changes: 1 addition & 1 deletion src/iterators/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ impl<A, D: Dimension> ExactSizeIterator for Baseiter<A, D> {
.slice()
.iter()
.zip(ix.slice().iter())
.fold(0, |s, (&a, &b)| s + a as usize * b as usize);
.fold(0, |s, (&a, &b)| s + a * b);
self.dim.size() - gone
}
}
Expand Down
1 change: 1 addition & 0 deletions src/zip/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ where
{
type Output = ArrayView<'a, A, E::Dim>;
fn broadcast_unwrap(self, shape: E) -> Self::Output {
#[allow(clippy::needless_borrow)]
let res: ArrayView<'_, A, E::Dim> = (&self).broadcast_unwrap(shape.into_dimension());
unsafe { ArrayView::new(res.ptr, res.dim, res.strides) }
}
Expand Down
3 changes: 3 additions & 0 deletions tests/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

use approx::assert_relative_eq;
use defmac::defmac;
#[allow(deprecated)]
use itertools::{zip, Itertools};
use ndarray::prelude::*;
use ndarray::{arr3, rcarr2};
Expand Down Expand Up @@ -499,12 +500,14 @@ fn test_index() {
*elt = i;
}

#[allow(deprecated)]
for ((i, j), a) in zip(indices((2, 3)), &A) {
assert_eq!(*a, A[[i, j]]);
}

let vi = A.slice(s![1.., ..;2]);
let mut it = vi.iter();
#[allow(deprecated)]
for ((i, j), x) in zip(indices((1, 2)), &mut it) {
assert_eq!(*x, vi[[i, j]]);
}
Expand Down
2 changes: 1 addition & 1 deletion xtest-blas/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ num-traits = "0.2"
num-complex = { version = "0.4", default-features = false }

[dependencies]
ndarray = { path = "../", features = ["approx", "blas"] }
ndarray = { path = "..", features = ["approx", "blas"] }

blas-src = { version = "0.8", optional = true }

Expand Down
7 changes: 1 addition & 6 deletions xtest-numeric/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ edition = "2018"
[dependencies]
approx = "0.4"
ndarray = { path = "..", features = ["approx"] }
ndarray-rand = { path = "../ndarray-rand/" }
ndarray-rand = { path = "../ndarray-rand" }
rand_distr = "0.4"

blas-src = { optional = true, version = "0.8", default-features = false, features = ["openblas"] }
Expand All @@ -27,8 +27,3 @@ test = false

[features]
test_blas = ["ndarray/blas", "blas-src", "openblas-src"]

[profile.dev]
opt-level = 2
[profile.test]
opt-level = 2
2 changes: 1 addition & 1 deletion xtest-serialization/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ publish = false
test = false

[dependencies]
ndarray = { path = "../", features = ["serde"] }
ndarray = { path = "..", features = ["serde"] }

[features]
default = ["ron"]
Expand Down