From f5d3e22b2cc6583ce636985c63d90fddb5037975 Mon Sep 17 00:00:00 2001 From: Stefan Kroboth Date: Fri, 3 Nov 2023 19:09:45 +0100 Subject: [PATCH 1/3] Added missing feature for testing argmin-math (docs) --- media/book/src/contributing.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/media/book/src/contributing.md b/media/book/src/contributing.md index 463e29e9c..af8f90d47 100644 --- a/media/book/src/contributing.md +++ b/media/book/src/contributing.md @@ -31,7 +31,7 @@ cargo test -p argmin-math Or the default features plus the latest `ndarray`/`nalgebra` backends: ```bash -cargo test -p argmin-math --features "latest_all" +cargo test -p argmin-math --features "latest_all,_dev_linalg_latest" ``` Individual backends can be tested as well; however, care has to be taken to not add two different versions of the same backend, as that may not work. From 73f06477d034b513bd9c89c44fd9ce193e03f830 Mon Sep 17 00:00:00 2001 From: Stefan Kroboth Date: Fri, 3 Nov 2023 19:13:15 +0100 Subject: [PATCH 2/3] Fixed typo in argmin/Cargo.toml --- argmin/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/argmin/Cargo.toml b/argmin/Cargo.toml index bcf4a3d69..d3357247c 100644 --- a/argmin/Cargo.toml +++ b/argmin/Cargo.toml @@ -54,7 +54,7 @@ serde1 = ["serde", "serde_json", "rand/serde1", "bincode", "slog-json", "rand_xo _ndarrayl = ["argmin-math/ndarray_latest-serde", "argmin-math/_dev_linalg_latest"] _nalgebral = ["argmin-math/nalgebra_latest-serde"] # When adding new features, please consider adding them to either `full` (for users) -# or `_full_dev` (only for local development, tesing and computing test coverage). +# or `_full_dev` (only for local development, testing and computing test coverage). full = ["default", "slog-logger", "serde1", "ctrlc"] _full_dev = ["full", "_ndarrayl", "_nalgebral"] From 05eabdbdfc286245002f3fbb8ac43fe52ccde2c3 Mon Sep 17 00:00:00 2001 From: Stefan Kroboth Date: Fri, 3 Nov 2023 19:23:58 +0100 Subject: [PATCH 3/3] Clippy --- argmin/src/solver/conjugategradient/cg.rs | 4 ++-- argmin/src/solver/linesearch/morethuente.rs | 8 ++++---- argmin/src/solver/particleswarm/mod.rs | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/argmin/src/solver/conjugategradient/cg.rs b/argmin/src/solver/conjugategradient/cg.rs index cb1bb7ccd..47276291c 100644 --- a/argmin/src/solver/conjugategradient/cg.rs +++ b/argmin/src/solver/conjugategradient/cg.rs @@ -247,10 +247,10 @@ mod tests { assert_relative_eq!(b[0], 1.0, epsilon = f64::EPSILON); assert_relative_eq!(b[1], 2.0, epsilon = f64::EPSILON); - let r0 = vec![2.0f64, 2.0]; + let r0 = [2.0f64, 2.0]; assert_relative_eq!(r0[0], r.as_ref().unwrap()[0], epsilon = f64::EPSILON); assert_relative_eq!(r0[1], r.as_ref().unwrap()[1], epsilon = f64::EPSILON); - let pp = vec![-2.0f64, -2.0]; + let pp = [-2.0f64, -2.0]; assert_relative_eq!(pp[0], p.as_ref().unwrap()[0], epsilon = f64::EPSILON); assert_relative_eq!(pp[1], p.as_ref().unwrap()[1], epsilon = f64::EPSILON); assert_relative_eq!(rtr, 8.0, epsilon = f64::EPSILON); diff --git a/argmin/src/solver/linesearch/morethuente.rs b/argmin/src/solver/linesearch/morethuente.rs index db9fdead4..5c915bddd 100644 --- a/argmin/src/solver/linesearch/morethuente.rs +++ b/argmin/src/solver/linesearch/morethuente.rs @@ -544,7 +544,7 @@ fn cstep( info = 1; bound = true; let theta = float!(3.0) * (stx.fx - stp.fx) / (stp.x - stx.x) + stx.gx + stp.gx; - let tmp = vec![theta, stx.gx, stp.gx]; + let tmp = [theta, stx.gx, stp.gx]; // Check for a NaN or Inf in tmp before sorting if tmp.iter().any(|n| n.is_nan() || n.is_infinite()) { return Err(argmin_error!( @@ -578,7 +578,7 @@ fn cstep( info = 2; bound = false; let theta = float!(3.0) * (stx.fx - stp.fx) / (stp.x - stx.x) + stx.gx + stp.gx; - let tmp = vec![theta, stx.gx, stp.gx]; + let tmp = [theta, stx.gx, stp.gx]; // Check for a NaN or Inf in tmp before sorting if tmp.iter().any(|n| n.is_nan() || n.is_infinite()) { return Err(argmin_error!( @@ -612,7 +612,7 @@ fn cstep( info = 3; bound = true; let theta = float!(3.0) * (stx.fx - stp.fx) / (stp.x - stx.x) + stx.gx + stp.gx; - let tmp = vec![theta, stx.gx, stp.gx]; + let tmp = [theta, stx.gx, stp.gx]; // Check for a NaN or Inf in tmp before sorting if tmp.iter().any(|n| n.is_nan() || n.is_infinite()) { return Err(argmin_error!( @@ -662,7 +662,7 @@ fn cstep( bound = false; if brackt { let theta = float!(3.0) * (stp.fx - sty.fx) / (sty.x - stp.x) + sty.gx + stp.gx; - let tmp = vec![theta, sty.gx, stp.gx]; + let tmp = [theta, sty.gx, stp.gx]; // Check for a NaN or Inf in tmp before sorting if tmp.iter().any(|n| n.is_nan() || n.is_infinite()) { return Err(argmin_error!( diff --git a/argmin/src/solver/particleswarm/mod.rs b/argmin/src/solver/particleswarm/mod.rs index 8230252d6..42e1021fb 100644 --- a/argmin/src/solver/particleswarm/mod.rs +++ b/argmin/src/solver/particleswarm/mod.rs @@ -198,8 +198,8 @@ where let mut particles = positions .into_iter() - .zip(velocities.into_iter()) - .zip(costs.into_iter()) + .zip(velocities) + .zip(costs) .map(|((p, v), c)| Particle::new(p, c, v)) .collect::>();