Skip to content

Commit

Permalink
don't return infinite error results
Browse files Browse the repository at this point in the history
  • Loading branch information
kevindlewis23 committed Jul 1, 2024
1 parent 373371c commit aff25dc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/correctness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ const TEST_ITERATIONS: usize = 1000;

#[test]
fn run_tests() {
// Seed fastrand
fastrand::seed(0);
let setups: Vec<Box<dyn SetupDynamic>> = vec![
Box::new(Subproblem6Setup::new()),
Box::new(Subproblem5Setup::new()),
Expand Down
8 changes: 6 additions & 2 deletions src/inverse_kinematics/auxiliary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,9 @@ pub fn search_1d<const N: usize, F: Fn(f64) -> Vector<f64, N> > (
if j == max_evals.len() - 1 {
let best_result = last_results.iter()
.min_by(|x, y| x.2.partial_cmp(&y.2).unwrap()).unwrap();
results.push((best_result.0, best_result.1))
if best_result.2.is_finite() {
results.push((best_result.0, best_result.1));
}
}
}
results
Expand Down Expand Up @@ -235,7 +237,9 @@ pub fn search_2d<const N: usize, F: Fn(f64, f64) -> Vector<f64, N>>(
if j == max_evals.len() - 1 {
let best_result = last_results.iter()
.min_by(|x, y| x.3.partial_cmp(&y.3).unwrap()).unwrap();
results.push((best_result.0, best_result.1, best_result.2))
if (best_result.3.is_finite()) {
results.push((best_result.0, best_result.1, best_result.2));
}
}
}

Expand Down

0 comments on commit aff25dc

Please sign in to comment.