From cf1d7f1ee9a8c49ef4f0466bb4fa54c649770e25 Mon Sep 17 00:00:00 2001 From: Dirreke Date: Thu, 15 Aug 2024 00:40:42 +0800 Subject: [PATCH 1/3] Upgrade deps --- ndarray-linalg/Cargo.toml | 6 +++--- ndarray-linalg/src/convert.rs | 10 +++++----- ndarray-linalg/tests/det.rs | 4 ++-- ndarray-linalg/tests/deth.rs | 4 ++-- ndarray-linalg/tests/inv.rs | 2 +- ndarray-linalg/tests/opnorm.rs | 4 ++-- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/ndarray-linalg/Cargo.toml b/ndarray-linalg/Cargo.toml index e06fa675..fd524609 100644 --- a/ndarray-linalg/Cargo.toml +++ b/ndarray-linalg/Cargo.toml @@ -37,7 +37,7 @@ rand = "0.8.3" thiserror = "1.0.24" [dependencies.ndarray] -version = "0.15.2" +version = "0.16.0" features = ["blas", "approx", "std"] default-features = false @@ -48,9 +48,9 @@ default-features = false [dev-dependencies] paste = "1.0.5" -criterion = "0.3.4" +criterion = "0.5.1" # Keep the same version as ndarray's dependency! -approx = { version = "0.4.0", features = ["num-complex"] } +approx = { version = "0.5", features = ["num-complex"] } rand_pcg = "0.3.1" [[bench]] diff --git a/ndarray-linalg/src/convert.rs b/ndarray-linalg/src/convert.rs index 43002966..c808211e 100644 --- a/ndarray-linalg/src/convert.rs +++ b/ndarray-linalg/src/convert.rs @@ -12,7 +12,7 @@ where S: Data, { let n = a.len(); - a.into_shape((n, 1)).unwrap() + a.into_shape_with_order((n, 1)).unwrap() } pub fn into_row(a: ArrayBase) -> ArrayBase @@ -20,7 +20,7 @@ where S: Data, { let n = a.len(); - a.into_shape((1, n)).unwrap() + a.into_shape_with_order((1, n)).unwrap() } pub fn flatten(a: ArrayBase) -> ArrayBase @@ -28,7 +28,7 @@ where S: Data, { let n = a.len(); - a.into_shape(n).unwrap() + a.into_shape_with_order(n).unwrap() } pub fn into_matrix(l: MatrixLayout, a: Vec) -> Result> @@ -99,9 +99,9 @@ where // https://github.com/bluss/rust-ndarray/issues/325 let strides: Vec = a.strides().to_vec(); let new = if a.is_standard_layout() { - ArrayBase::from_shape_vec(a.dim(), a.into_raw_vec()).unwrap() + ArrayBase::from_shape_vec(a.dim(), a.into_raw_vec_and_offset().0).unwrap() } else { - ArrayBase::from_shape_vec(a.dim().f(), a.into_raw_vec()).unwrap() + ArrayBase::from_shape_vec(a.dim().f(), a.into_raw_vec_and_offset().0).unwrap() }; assert_eq!( new.strides(), diff --git a/ndarray-linalg/tests/det.rs b/ndarray-linalg/tests/det.rs index d14fc8d0..40dafd57 100644 --- a/ndarray-linalg/tests/det.rs +++ b/ndarray-linalg/tests/det.rs @@ -94,7 +94,7 @@ fn det_zero_nonsquare() { assert!(a.sln_det_into().is_err()); }; } - for &shape in &[(1, 2).into_shape(), (1, 2).f()] { + for &shape in &[(1, 2).into_shape_with_order(), (1, 2).f()] { det_zero_nonsquare!(f64, shape); det_zero_nonsquare!(f32, shape); det_zero_nonsquare!(c64, shape); @@ -186,7 +186,7 @@ fn det_nonsquare() { }; } for &dims in &[(1, 0), (1, 2), (2, 1), (2, 3)] { - for &shape in &[dims.into_shape(), dims.f()] { + for &shape in &[dims.into_shape_with_order(), dims.f()] { det_nonsquare!(f64, shape); det_nonsquare!(f32, shape); det_nonsquare!(c64, shape); diff --git a/ndarray-linalg/tests/deth.rs b/ndarray-linalg/tests/deth.rs index 4785aadc..9079c342 100644 --- a/ndarray-linalg/tests/deth.rs +++ b/ndarray-linalg/tests/deth.rs @@ -60,7 +60,7 @@ fn deth_zero_nonsquare() { assert!(a.sln_deth_into().is_err()); }; } - for &shape in &[(1, 2).into_shape(), (1, 2).f()] { + for &shape in &[(1, 2).into_shape_with_order(), (1, 2).f()] { deth_zero_nonsquare!(f64, shape); deth_zero_nonsquare!(f32, shape); deth_zero_nonsquare!(c64, shape); @@ -138,7 +138,7 @@ fn deth_nonsquare() { }; } for &dims in &[(1, 0), (1, 2), (2, 1), (2, 3)] { - for &shape in &[dims.into_shape(), dims.f()] { + for &shape in &[dims.into_shape_with_order(), dims.f()] { deth_nonsquare!(f64, shape); deth_nonsquare!(f32, shape); deth_nonsquare!(c64, shape); diff --git a/ndarray-linalg/tests/inv.rs b/ndarray-linalg/tests/inv.rs index 030773c1..7dab3e01 100644 --- a/ndarray-linalg/tests/inv.rs +++ b/ndarray-linalg/tests/inv.rs @@ -106,7 +106,7 @@ fn inv_into_random_complex() { #[should_panic] fn inv_error() { // do not have inverse - let a = Array::::zeros(9).into_shape((3, 3)).unwrap(); + let a = Array::::zeros(9).into_shape_with_order((3, 3)).unwrap(); let a_inv = a.inv().unwrap(); println!("{:?}", a_inv); } diff --git a/ndarray-linalg/tests/opnorm.rs b/ndarray-linalg/tests/opnorm.rs index abd41748..b00c149f 100644 --- a/ndarray-linalg/tests/opnorm.rs +++ b/ndarray-linalg/tests/opnorm.rs @@ -14,11 +14,11 @@ fn gen(i: usize, j: usize, rev: bool) -> Array2 { let n = (i * j + 1) as f64; if rev { Array::range(1., n, 1.) - .into_shape((j, i)) + .into_shape_with_order((j, i)) .unwrap() .reversed_axes() } else { - Array::range(1., n, 1.).into_shape((i, j)).unwrap() + Array::range(1., n, 1.).into_shape_with_order((i, j)).unwrap() } } From fc0f0ef572caad8b9a59e12feb18f1fd9114bf63 Mon Sep 17 00:00:00 2001 From: Ulrik Sverdrup Date: Sat, 23 Nov 2024 18:32:10 +0100 Subject: [PATCH 2/3] ndarray-linalg: Update to lax 0.16.0 --- ndarray-linalg/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ndarray-linalg/Cargo.toml b/ndarray-linalg/Cargo.toml index fd524609..bda7a89c 100644 --- a/ndarray-linalg/Cargo.toml +++ b/ndarray-linalg/Cargo.toml @@ -42,7 +42,7 @@ features = ["blas", "approx", "std"] default-features = false [dependencies.lax] -version = "0.16.0-rc.0" +version = "0.16.0" path = "../lax" default-features = false From 3545492b9bc994eaf14ce0dc0d7f1eebc6c1b65c Mon Sep 17 00:00:00 2001 From: Ulrik Sverdrup Date: Sat, 23 Nov 2024 18:39:52 +0100 Subject: [PATCH 3/3] Run cargo fmt --- ndarray-linalg/tests/inv.rs | 4 +++- ndarray-linalg/tests/opnorm.rs | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ndarray-linalg/tests/inv.rs b/ndarray-linalg/tests/inv.rs index 7dab3e01..93ff1aad 100644 --- a/ndarray-linalg/tests/inv.rs +++ b/ndarray-linalg/tests/inv.rs @@ -106,7 +106,9 @@ fn inv_into_random_complex() { #[should_panic] fn inv_error() { // do not have inverse - let a = Array::::zeros(9).into_shape_with_order((3, 3)).unwrap(); + let a = Array::::zeros(9) + .into_shape_with_order((3, 3)) + .unwrap(); let a_inv = a.inv().unwrap(); println!("{:?}", a_inv); } diff --git a/ndarray-linalg/tests/opnorm.rs b/ndarray-linalg/tests/opnorm.rs index b00c149f..cd45d258 100644 --- a/ndarray-linalg/tests/opnorm.rs +++ b/ndarray-linalg/tests/opnorm.rs @@ -18,7 +18,9 @@ fn gen(i: usize, j: usize, rev: bool) -> Array2 { .unwrap() .reversed_axes() } else { - Array::range(1., n, 1.).into_shape_with_order((i, j)).unwrap() + Array::range(1., n, 1.) + .into_shape_with_order((i, j)) + .unwrap() } }