Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
BjornTheProgrammer authored Aug 1, 2024
2 parents 4a3fc8f + f9258f2 commit 62dea6a
Show file tree
Hide file tree
Showing 17 changed files with 68 additions and 66 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ jobs:
- stable
- beta
- nightly
- 1.57.0 # MSRV
- 1.64.0 # MSRV

name: tests/${{ matrix.rust }}
steps:
Expand Down
29 changes: 20 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
name = "ndarray"
version = "0.15.6"
edition = "2018"
rust-version = "1.57"
rust-version = "1.64"
authors = [
"Ulrik Sverdrup \"bluss\"",
"Jim Turner"
Expand Down Expand Up @@ -31,12 +31,11 @@ num-integer = { version = "0.1.39", default-features = false }
num-traits = { version = "0.2", default-features = false }
num-complex = { version = "0.4", default-features = false }

# Use via the `rayon` crate feature!
rayon_ = { version = "1.0.3", optional = true, package = "rayon" }
rayon = { version = "1.10.0", optional = true }

approx = { version = "0.5", optional = true , default-features = false }

# Use via the `blas` crate feature!
# Use via the `blas` crate feature
cblas-sys = { version = "0.1.4", optional = true, default-features = false }
libc = { version = "0.2.82", optional = true }

Expand All @@ -50,17 +49,18 @@ rawpointer = { version = "0.2" }
defmac = "0.2"
quickcheck = { version = "1.0", default-features = false }
approx = "0.5"
itertools = { version = "0.10.0", default-features = false, features = ["use_std"] }
itertools = { version = "0.13.0", default-features = false, features = ["use_std"] }

[features]
default = ["std"]

# Enable blas usage
# See README for more instructions
blas = ["cblas-sys", "libc"]
blas = ["dep:cblas-sys", "dep:libc"]

serde = ["dep:serde"]
# Old name for the serde feature
serde-1 = ["serde"]
serde-1 = ["dep:serde"]

# These features are used for testing
test = []
Expand All @@ -69,7 +69,7 @@ test = []
docs = ["approx", "serde", "rayon"]

std = ["num-traits/std", "matrixmultiply/std"]
rayon = ["rayon_", "std"]
rayon = ["dep:rayon", "std"]

critical-section = ["portable-atomic/critical-section"]

Expand Down Expand Up @@ -97,7 +97,18 @@ opt-level = 2
opt-level = 2

[workspace]
members = ["ndarray-rand", "xtest-serialization", "xtest-blas", "xtest-numeric"]
members = [
"ndarray-rand",
"extra-tests/serialization",
"extra-tests/blas",
"extra-tests/numeric",
]

[workspace.dependencies]
ndarray = { path = "." }
num-traits = { version = "0.2", default-features = false }
num-complex = { version = "0.4", default-features = false }
ndarray-rand = { path = "./ndarray-rand" }

[package.metadata.release]
no-dev-version = true
Expand Down
5 changes: 5 additions & 0 deletions extra-tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

# Extra Tests

These are test crates whose settings, features and dependencies should be
separate from the main crate.
9 changes: 5 additions & 4 deletions xtest-blas/Cargo.toml → extra-tests/blas/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,21 @@ name = "blas-tests"
version = "0.1.0"
authors = ["bluss"]
publish = false
edition = "2018"

[lib]
test = false

[dev-dependencies]
approx = "0.5"
defmac = "0.2"
num-traits = "0.2"
num-complex = { version = "0.4", default-features = false }
num-traits = { workspace = true }
num-complex = { workspace = true }

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

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

openblas-src = { version = "0.10", optional = true }
netlib-src = { version = "0.8", optional = true }
Expand Down
File renamed without changes.
File renamed without changes.
10 changes: 5 additions & 5 deletions xtest-numeric/Cargo.toml → extra-tests/numeric/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@ edition = "2018"

[dependencies]
approx = "0.5"
ndarray = { path = "..", features = ["approx"] }
ndarray-rand = { path = "../ndarray-rand" }
ndarray = { workspace = true, features = ["approx"] }
ndarray-rand = { workspace = true }
rand_distr = "0.4"

blas-src = { optional = true, version = "0.8", default-features = false, features = ["openblas"] }
blas-src = { optional = true, version = "0.10", default-features = false, features = ["openblas"] }
openblas-src = { optional = true, version = "0.10", default-features = false, features = ["cblas", "system"] }

[dependencies.rand]
version = "0.8.0"
features = ["small_rng"]

[dev-dependencies]
num-traits = { version = "0.2.14", default-features = false }
num-complex = { version = "0.4", default-features = false }
num-traits = { workspace = true }
num-complex = { workspace = true }

[lib]
test = false
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,9 @@ fn random_matrix_mul<A>(
) -> (Array2<A>, Array2<A>)
where A: LinalgScalar
{
let m = rng.gen_range(15..512);
let k = rng.gen_range(15..512);
let n = rng.gen_range(15..1560);
let m = rng.gen_range(15..128);
let k = rng.gen_range(15..128);
let n = rng.gen_range(15..512);
let a = generator(Ix2(m, k), rng);
let b = generator(Ix2(n, k), rng);
let c = if use_general {
Expand Down Expand Up @@ -261,7 +261,7 @@ fn accurate_mul_with_column_f64()
// pick a few random sizes
let rng = &mut SmallRng::from_entropy();
for i in 0..10 {
let m = rng.gen_range(1..350);
let m = rng.gen_range(1..128);
let k = rng.gen_range(1..350);
let a = gen::<f64, _>(Ix2(m, k), rng);
let b_owner = gen::<f64, _>(Ix2(k, k), rng);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ name = "serialization-tests"
version = "0.1.0"
authors = ["bluss"]
publish = false
edition = "2018"

[lib]
test = false

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

[features]
default = ["ron"]
Expand All @@ -20,9 +21,14 @@ default-features = false
[dev-dependencies.serde_json]
version = "1.0.40"

[dev-dependencies.rmp]
# Old version to work with Rust 1.64+
version = "=0.8.10"

[dev-dependencies.rmp-serde]
version = "0.14.0"
# Old version to work with Rust 1.64+
version = "0.14"

[dependencies.ron]
version = "0.5.1"
version = "0.8.1"
optional = true
File renamed without changes.
File renamed without changes.
33 changes: 8 additions & 25 deletions scripts/all-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,19 @@ set -e
FEATURES=$1
CHANNEL=$2

if [ "$CHANNEL" = "1.57.0" ]; then
cargo update --package openblas-src --precise 0.10.5
cargo update --package openblas-build --precise 0.10.5
cargo update --package once_cell --precise 1.14.0
cargo update --package byteorder --precise 1.4.3
cargo update --package rayon --precise 1.5.3
cargo update --package rayon-core --precise 1.9.3
cargo update --package crossbeam-channel --precise 0.5.8
cargo update --package crossbeam-deque --precise 0.8.3
cargo update --package crossbeam-epoch --precise 0.9.15
cargo update --package crossbeam-utils --precise 0.8.16
cargo update --package rmp --precise 0.8.11
cargo update --package serde_json --precise 1.0.99
cargo update --package serde --precise 1.0.156
cargo update --package thiserror --precise 1.0.39
cargo update --package quote --precise 1.0.30
cargo update --package proc-macro2 --precise 1.0.65
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
cargo test --release --verbose --no-default-features
cargo build --verbose --features "$FEATURES"
cargo test --verbose --features "$FEATURES"
cargo test --manifest-path=ndarray-rand/Cargo.toml --no-default-features --verbose
cargo test --manifest-path=ndarray-rand/Cargo.toml --features quickcheck --verbose
cargo test --manifest-path=xtest-serialization/Cargo.toml --verbose
cargo test --manifest-path=xtest-blas/Cargo.toml --verbose --features openblas-system
cargo test -p ndarray-rand --no-default-features --verbose
cargo test -p ndarray-rand --features ndarray-rand/quickcheck --verbose

cargo test -p serialization-tests -v
cargo test -p blas-tests -v --features blas-tests/openblas-system
cargo test -p numeric-tests -v
cargo test -p numeric-tests -v --features numeric-tests/test_blas

cargo test --examples
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")
6 changes: 3 additions & 3 deletions scripts/cross-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ TARGET=$3

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
cross test -v --no-fail-fast --target=$TARGET --manifest-path=xtest-numeric/Cargo.toml --release
cross test -v --no-fail-fast --target=$TARGET -p ndarray-rand --features ndarray-rand/quickcheck
cross test -v --no-fail-fast --target=$TARGET -p serialization-tests --verbose
cross test -v --no-fail-fast --target=$TARGET -p numeric-tests --release
2 changes: 1 addition & 1 deletion src/impl_methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2623,7 +2623,7 @@ where
let dim = self.raw_dim();
Zip::from(LanesMut::new(self.view_mut(), Axis(n - 1)))
.and(Lanes::new(rhs.broadcast_assume(dim), Axis(n - 1)))
.for_each(move |s_row, r_row| Zip::from(s_row).and(r_row).for_each(|a, b| f(a, b)));
.for_each(move |s_row, r_row| Zip::from(s_row).and(r_row).for_each(&mut f));
}

fn zip_mut_with_elem<B, F>(&mut self, rhs_elem: &B, mut f: F)
Expand Down
8 changes: 2 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,10 @@
#![doc(html_logo_url = "https://rust-ndarray.github.io/images/rust-ndarray_logo.svg")]
#![allow(
unstable_name_collisions, // our `PointerExt` collides with upcoming inherent methods on `NonNull`
clippy::many_single_char_names,
clippy::deref_addrof,
clippy::unreadable_literal,
clippy::manual_map, // is not an error
clippy::while_let_on_iterator, // is not an error
clippy::from_iter_instead_of_collect, // using from_iter is good style
clippy::redundant_closure, // false positives clippy #7812
clippy::incompatible_msrv, // false positive PointerExt::offset
)]
#![doc(test(attr(deny(warnings))))]
Expand Down Expand Up @@ -72,7 +69,8 @@
//! needs matching memory layout to be efficient (with some exceptions).
//! + Efficient floating point matrix multiplication even for very large
//! matrices; can optionally use BLAS to improve it further.
//! - **Requires Rust 1.57 or later**
//!
//! - **MSRV: Requires Rust 1.64 or later**
//!
//! ## Crate Feature Flags
//!
Expand Down Expand Up @@ -1590,8 +1588,6 @@ where

// parallel methods
#[cfg(feature = "rayon")]
extern crate rayon_ as rayon;
#[cfg(feature = "rayon")]
pub mod parallel;

mod impl_1d;
Expand Down
10 changes: 5 additions & 5 deletions src/linalg/impl_linalg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -823,11 +823,11 @@ where
if !same_type::<A, S::Elem>() {
return false;
}
if a.len() > blas_index::max_value() as usize {
if a.len() > blas_index::MAX as usize {
return false;
}
let stride = a.strides()[0];
if stride == 0 || stride > blas_index::max_value() as isize || stride < blas_index::min_value() as isize {
if stride == 0 || stride > blas_index::MAX as isize || stride < blas_index::MIN as isize {
return false;
}
true
Expand Down Expand Up @@ -882,12 +882,12 @@ fn is_blas_2d(dim: &Ix2, stride: &Ix2, order: MemoryOrder) -> bool
if s0 < 1 || s1 < 1 {
return false;
}
if (s0 > blas_index::max_value() as isize || s0 < blas_index::min_value() as isize)
|| (s1 > blas_index::max_value() as isize || s1 < blas_index::min_value() as isize)
if (s0 > blas_index::MAX as isize || s0 < blas_index::MIN as isize)
|| (s1 > blas_index::MAX as isize || s1 < blas_index::MIN as isize)
{
return false;
}
if m > blas_index::max_value() as usize || n > blas_index::max_value() as usize {
if m > blas_index::MAX as usize || n > blas_index::MAX as usize {
return false;
}
true
Expand Down

0 comments on commit 62dea6a

Please sign in to comment.