Skip to content

Commit 19db90e

Browse files
Merge remote-tracking branch 'origin/master' into nd-dot-ix2
# Conflicts: # src/indexes.rs # src/iterators/mod.rs
2 parents 150a49d + 53df84a commit 19db90e

21 files changed

Lines changed: 212 additions & 70 deletions

File tree

‎.github/workflows/latest-deps.yaml‎

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
name: Check Latest Dependencies
22
on:
33
schedule:
4-
# Chosen so that it runs right before the international date line experiences the weekend.
5-
# Since we're open source, that means globally we should be aware of it right when we have the most
6-
# time to fix it.
7-
#
8-
# Sorry if this ruins your weekend, future maintainer...
9-
- cron: '0 12 * * FRI'
4+
# Daily, so that new Rust releases (lints, deprecations) or dependency releases that break
5+
# the build are caught before they show up as failures on unrelated PRs.
6+
- cron: '0 12 * * *'
107
workflow_dispatch: # For running manually
118
pull_request:
129
paths:
@@ -20,6 +17,24 @@ env:
2017
MSRV: 1.87.0
2118

2219
jobs:
20+
latest_clippy_stable:
21+
runs-on: ubuntu-latest
22+
name: Check Clippy with Latest Dependencies on Stable
23+
steps:
24+
- name: Check Out Repo
25+
uses: actions/checkout@v4
26+
- name: Install Rust
27+
uses: dtolnay/rust-toolchain@master
28+
with:
29+
toolchain: stable
30+
components: clippy
31+
- name: Setup Rust Cache
32+
uses: Swatinem/rust-cache@v2
33+
- name: Ensure latest dependencies
34+
run: cargo update
35+
- name: Run Clippy
36+
run: cargo clippy -F "$FEATURES"
37+
2338
latest_deps_stable:
2439
runs-on: ubuntu-latest
2540
name: Check Latest Dependencies on Stable

‎Cargo.lock‎

Lines changed: 32 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Cargo.toml‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ rayon = { version = "1.10.0", optional = true }
4646
cblas-sys = { workspace = true, optional = true }
4747
libc = { version = "0.2.82", optional = true }
4848

49-
matrixmultiply = { version = "0.3.2", default-features = false, features=["cgemm"] }
49+
matrixmultiply = { version = "0.3.11", default-features = false, features=["avx512", "cgemm"] }
5050

5151
serde = { version = "1.0", optional = true, default-features = false, features = ["alloc"] }
5252
rawpointer = { version = "0.2" }
@@ -105,8 +105,8 @@ num-complex = { version = "0.4", default-features = false }
105105
approx = { version = "0.5", default-features = false }
106106
quickcheck = { version = "1.0", default-features = false }
107107
proptest = { version = "1.3.1" }
108-
rand = { version = "0.9.0", features = ["small_rng"] }
109-
rand_distr = { version = "0.5.0" }
108+
rand = { version = "0.10.0" }
109+
rand_distr = { version = "0.6.0" }
110110
itertools = { version = "0.13.0", default-features = false, features = ["use_std"] }
111111
cblas-sys = { version = "0.1.4", default-features = false }
112112

‎README-quick-start.md‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ Basic operations on arrays are all element-wise; you need to use specific method
108108
```rust
109109
use ndarray::prelude::*;
110110
use ndarray::Array;
111-
use std::f64::INFINITY as inf;
112111

113112
fn main() {
114113
let a = array![
@@ -119,7 +118,7 @@ fn main() {
119118
assert_eq!(&a + &b, array![[10., 21., 32., 43.,]]); // Allocates a new array. Note the explicit `&`.
120119
assert_eq!(&a - &b, array![[10., 19., 28., 37.,]]);
121120
assert_eq!(&a * &b, array![[0., 20., 60., 120.,]]);
122-
assert_eq!(&a / &b, array![[inf, 20., 15., 13.333333333333334,]]);
121+
assert_eq!(&a / &b, array![[f64::INFINITY, 20., 15., 13.333333333333334,]]);
123122
}
124123
```
125124

@@ -306,7 +305,7 @@ use std::iter::FromIterator;
306305

307306
fn main() {
308307
// Or you may use ndarray_rand crate to generate random arrays
309-
// let a = Array::random((2, 5), Uniform::new(0., 10.));
308+
// let a = Array::random((2, 5), Uniform::new(0., 10.).unwrap());
310309

311310
let a = array![
312311
[3., 7., 3., 4.],

‎crates/numeric-tests/tests/accuracy.rs‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use std::fmt;
1010

1111
use ndarray_rand::RandomExt;
1212
use rand::rngs::SmallRng;
13-
use rand::{Rng, SeedableRng};
13+
use rand::{RngExt, SeedableRng};
1414

1515
use ndarray::linalg::general_mat_mul;
1616
use ndarray::prelude::*;
@@ -86,7 +86,7 @@ where
8686
#[test]
8787
fn accurate_eye_f32()
8888
{
89-
let rng = &mut SmallRng::from_os_rng();
89+
let rng = &mut SmallRng::from_rng(&mut rand::rng());
9090
for i in 0..20 {
9191
let eye = Array::eye(i);
9292
for j in 0..20 {
@@ -114,7 +114,7 @@ fn accurate_eye_f32()
114114
#[test]
115115
fn accurate_eye_f64()
116116
{
117-
let rng = &mut SmallRng::from_os_rng();
117+
let rng = &mut SmallRng::from_rng(&mut rand::rng());
118118
let abs_tol = 1e-15;
119119
for i in 0..20 {
120120
let eye = Array::eye(i);
@@ -209,7 +209,7 @@ where
209209
A: fmt::Debug,
210210
{
211211
// pick a few random sizes
212-
let mut rng = SmallRng::from_os_rng();
212+
let mut rng = SmallRng::from_rng(&mut rand::rng());
213213
for i in 0..20 {
214214
let (c, reference) = random_matrix_mul(&mut rng, i > 10, use_general, gen::<A, _>);
215215

@@ -241,7 +241,7 @@ where
241241
A: fmt::Debug,
242242
{
243243
// pick a few random sizes
244-
let mut rng = SmallRng::from_os_rng();
244+
let mut rng = SmallRng::from_rng(&mut rand::rng());
245245
for i in 0..20 {
246246
let (c, reference) = random_matrix_mul(&mut rng, i > 10, true, gen_complex::<A, _>);
247247

@@ -259,7 +259,7 @@ where
259259
fn accurate_mul_with_column_f64()
260260
{
261261
// pick a few random sizes
262-
let rng = &mut SmallRng::from_os_rng();
262+
let rng = &mut SmallRng::from_rng(&mut rand::rng());
263263
for i in 0..10 {
264264
let m = rng.random_range(1..128);
265265
let k = rng.random_range(1..350);

‎ndarray-rand/Cargo.toml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "ndarray-rand"
3-
version = "0.16.0"
3+
version = "0.17.0"
44
edition = "2018"
55
authors = ["bluss"]
66
license = "MIT OR Apache-2.0"
@@ -29,7 +29,7 @@ rand_distr = { workspace = true }
2929
quickcheck = { workspace = true, optional = true }
3030

3131
[dev-dependencies]
32-
rand_isaac = "0.4.0"
32+
rand_isaac = "0.5.0"
3333
quickcheck = { workspace = true }
3434

3535
[package.metadata.release]

‎ndarray-rand/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use ndarray_rand::RandomExt;
1515
use ndarray_rand::rand_distr::Uniform;
1616

1717
fn main() {
18-
let a = Array::random((2, 5), Uniform::new(0., 10.));
18+
let a = Array::random((2, 5), Uniform::new(0., 10.).unwrap());
1919
println!("{:8.4}", a);
2020
// Example Output:
2121
// [[ 8.6900, 6.9824, 3.8922, 6.5861, 2.4890],

‎ndarray-rand/RELEASES.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
Recent Changes
22
--------------
33

4+
- 0.17.0
5+
6+
- Bump `rand` to 0.10.0 and `rand_distr` to 0.6.0
7+
48
- 0.16.0
59

610
- Require ndarray 0.17.1

‎ndarray-rand/src/lib.rs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@
1212
//!
1313
//! ## Note
1414
//!
15-
//! `ndarray-rand` depends on [`rand` 0.9][rand].
15+
//! `ndarray-rand` depends on [`rand` 0.10][rand].
1616
//!
1717
//! [`rand`][rand] and [`rand_distr`][rand_distr]
1818
//! are re-exported as sub-modules, [`ndarray_rand::rand`](rand)
1919
//! and [`ndarray_rand::rand_distr`](rand_distr) respectively.
2020
//! You can use these submodules for guaranteed version compatibility or
2121
//! convenience.
2222
//!
23-
//! [rand]: https://docs.rs/rand/0.9
24-
//! [rand_distr]: https://docs.rs/rand_distr/0.5
23+
//! [rand]: https://docs.rs/rand/0.10
24+
//! [rand_distr]: https://docs.rs/rand_distr/0.6
2525
//!
2626
//! If you want to use a random number generator or distribution from another crate
2727
//! with `ndarray-rand`, you need to make sure that the other crate also depends on the

‎src/dimension/dimension_trait.rs‎

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -375,18 +375,24 @@ pub trait Dimension:
375375
IxDyn(self.slice())
376376
}
377377

378+
/// Creates a dimension of this type from a slice of axis lengths.
379+
///
380+
/// Returns `None` if the slice length is incompatible with this
381+
/// dimension type's dimensionality
382+
fn from_slice(ix: &[Ix]) -> Option<Self>
383+
{
384+
if Self::NDIM.is_some_and(|n| n != ix.len()) {
385+
return None;
386+
}
387+
let mut s = Self::zeros(ix.len());
388+
s.slice_mut().copy_from_slice(ix);
389+
Some(s)
390+
}
391+
378392
#[doc(hidden)]
379393
fn from_dimension<D2: Dimension>(d: &D2) -> Option<Self>
380394
{
381-
let mut s = Self::default();
382-
if s.ndim() == d.ndim() {
383-
for i in 0..d.ndim() {
384-
s[i] = d[i];
385-
}
386-
Some(s)
387-
} else {
388-
None
389-
}
395+
Self::from_slice(d.slice())
390396
}
391397

392398
#[doc(hidden)]
@@ -584,15 +590,6 @@ impl Dimension for Dim<[Ix; 1]>
584590
{
585591
self.remove_axis(axis)
586592
}
587-
588-
fn from_dimension<D2: Dimension>(d: &D2) -> Option<Self>
589-
{
590-
if 1 == d.ndim() {
591-
Some(Ix1(d[0]))
592-
} else {
593-
None
594-
}
595-
}
596593
private_impl! {}
597594
}
598595

@@ -1003,9 +1000,9 @@ impl Dimension for IxDyn
10031000
}
10041001
}
10051002

1006-
fn from_dimension<D2: Dimension>(d: &D2) -> Option<Self>
1003+
fn from_slice(ix: &[Ix]) -> Option<Self>
10071004
{
1008-
Some(IxDyn(d.slice()))
1005+
Some(IxDyn(ix))
10091006
}
10101007

10111008
fn into_dyn(self) -> IxDyn

0 commit comments

Comments
 (0)