Skip to content
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
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ readme = "README.md"

[dependencies]
sample-consensus = "1.0.1"
rand_core = "0.6.3"
rand_core = "0.9"

[dev-dependencies]
rand = "0.8.4"
rand_xoshiro = "0.6.0"
rand = "0.9"
rand_xoshiro = "0.7"

[profile.dev]
opt-level = 3
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ where
}
}

(inliers >= minimum_samples).then(|| inliers)
(inliers >= minimum_samples).then_some(inliers)
}

/// Determines the number of inliers a model has.
Expand Down
17 changes: 10 additions & 7 deletions tests/lines.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use arrsac::Arrsac;
use rand::distributions::Uniform;
use rand::{distributions::Distribution, Rng, SeedableRng};
use rand::{
distr::{Distribution, Uniform},
Rng, SeedableRng,
};
use rand_xoshiro::Xoshiro256PlusPlus;
use sample_consensus::{Consensus, Estimator, Model};

Expand Down Expand Up @@ -89,18 +91,19 @@ fn lines() {

for _ in 0..2000 {
// Generate <a, b> and normalize.
let norm = Vector2::new(rng.gen_range(-10.0..10.0), rng.gen_range(-10.0..10.0)).normalize();
let norm =
Vector2::new(rng.random_range(-10.0..10.0), rng.random_range(-10.0..10.0)).normalize();
// Get parallel ray.
let ray = Vector2::new(norm.y, -norm.x);
// Generate random c.
let c = rng.gen_range(-10.0..10.0);
let c = rng.random_range(-10.0..10.0);

// Generate random number of points between 50 and 1000.
let num = rng.gen_range(50..1000);
let num = rng.random_range(50..1000);
// The points should be no more than 5.0 away from the line and be evenly distributed away from the line.
let residuals = Uniform::new(-5.0, 5.0);
let residuals = Uniform::new(-5.0, 5.0).unwrap();
// The points must be generated along the line, but the distance should be bounded to make it more difficult.
let distances = Uniform::new(-50.0, 50.0);
let distances = Uniform::new(-50.0, 50.0).unwrap();
// Generate the points.
let points: Vec<Vector2<f64>> = (0..num)
.map(|_| {
Expand Down
2 changes: 1 addition & 1 deletion tests/no_solutions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use rand::SeedableRng;
use rand_xoshiro::Xoshiro256PlusPlus;
use sample_consensus::{Consensus, Estimator, Model};

pub struct Unsolvable(f64);
pub struct Unsolvable(#[allow(dead_code)] f64);

impl Model<i32> for Unsolvable {
fn residual(&self, _data: &i32) -> f64 {
Expand Down
Loading