Skip to content

Commit

Permalink
Fix error handling in least_squares tests
Browse files Browse the repository at this point in the history
  • Loading branch information
termoshtt committed Jul 1, 2020
1 parent 492059f commit d81aff5
Showing 1 changed file with 2 additions and 13 deletions.
15 changes: 2 additions & 13 deletions ndarray-linalg/src/least_squares.rs
Original file line number Diff line number Diff line change
Expand Up @@ -719,20 +719,14 @@ mod tests {
// Testing error cases
//
use crate::layout::MatrixLayout;
use ndarray::ErrorKind;

#[test]
fn test_incompatible_shape_error_on_mismatching_num_rows() {
let a: Array2<f64> = array![[1., 2.], [4., 5.], [3., 4.]];
let b: Array1<f64> = array![1., 2.];
let res = a.least_squares(&b);
match res {
Err(err) => match err {
LinalgError::Shape(shape_error) => {
assert_eq!(shape_error.kind(), ErrorKind::IncompatibleShape)
}
_ => panic!("Expected ShapeError"),
},
Err(LinalgError::Lapack(err)) if matches!(err, lapack::error::Error::InvalidShape) => {}
_ => panic!("Expected Err()"),
}
}
Expand All @@ -745,12 +739,7 @@ mod tests {

let res = a.least_squares(&b);
match res {
Err(err) => match err {
LinalgError::Shape(shape_error) => {
assert_eq!(shape_error.kind(), ErrorKind::IncompatibleShape)
}
_ => panic!("Expected ShapeError"),
},
Err(LinalgError::Lapack(err)) if matches!(err, lapack::error::Error::InvalidShape) => {}
_ => panic!("Expected Err()"),
}
}
Expand Down

0 comments on commit d81aff5

Please sign in to comment.