Skip to content

Commit

Permalink
Merge pull request #51 from NREL/f2-remove-unwrap
Browse files Browse the repository at this point in the history
replaced unwrap with bail and some error context
  • Loading branch information
kylecarow authored Sep 1, 2023
2 parents c24c138 + 321a9c7 commit 07838d5
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion rust/fastsim-core/src/simdrive/simdrive_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1050,7 +1050,17 @@ impl RustSimDrive {

let _ys = Array::from_vec(ys).map(|x| x.abs());
self.mps_ach[i] = max(
xs[_ys.iter().position(|&x| x == ndarrmin(&_ys)).unwrap()],
xs[match _ys.iter().position(|&x| x == ndarrmin(&_ys)) {
Some(pos) => pos,
None => bail!(
"[{}:{}]
ndarrmin(&_ys): {}
",
file!(),
line!(),
ndarrmin(&_ys),
),
}],
0.0,
);
grade_estimate = self.lookup_grade_for_step(i, Some(self.mps_ach[i]));
Expand Down

0 comments on commit 07838d5

Please sign in to comment.