Skip to content

Commit

Permalink
Fix dependency, doc test and formatting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Körbitz authored and Paul Körbitz committed Jun 24, 2020
1 parent 36b47c8 commit def3ecc
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 22 deletions.
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ optional = true
paste = "0.1.9"
criterion = "0.3.1"
approx = { version = "0.3.2", features = ["num-complex"] }
num-complex = "0.3.0"

[[bench]]
name = "truncated_eig"
Expand Down
41 changes: 20 additions & 21 deletions src/least_squares.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
//! ## Example
//! ```rust
//! use approx::AbsDiffEq; // for abs_diff_eq
//! use ndarray::{Array1, Array2};
//! use ndarray::{array, Array1, Array2};
//! use ndarray_linalg::{LeastSquaresSvd, LeastSquaresSvdInto, LeastSquaresSvdInPlace};
//!
//! let a: Array2<f64> = array![
Expand Down Expand Up @@ -213,7 +213,7 @@ where
impl<E, D> LeastSquaresSvdInto<D, E, Ix1> for ArrayBase<D, Ix2>
where
E: Scalar + Lapack + LeastSquaresSvdDivideConquer_,
D: DataMut<Elem = E>,
D: DataMut<Elem = E>,
{
/// Solve a least squares problem of the form `Ax = rhs`
/// by calling `A.least_squares(rhs)`, where `rhs` is a
Expand All @@ -239,7 +239,7 @@ where
impl<E, D> LeastSquaresSvdInto<D, E, Ix2> for ArrayBase<D, Ix2>
where
E: Scalar + Lapack + LeastSquaresSvdDivideConquer_,
D: DataMut<Elem = E>,
D: DataMut<Elem = E>,
{
/// Solve a least squares problem of the form `Ax = rhs`
/// by calling `A.least_squares(rhs)`, where `rhs` is a
Expand Down Expand Up @@ -548,8 +548,8 @@ mod tests {

///////////////////////////////////////////////////////////////////////////
/// Test that the different lest squares traits work as intended on the
/// different array types.
///
/// different array types.
///
/// | least_squares | ls_into | ls_in_place |
/// --------------+---------------+---------+-------------+
/// Array | yes | yes | yes |
Expand Down Expand Up @@ -674,7 +674,6 @@ mod tests {
assert_result(&a, &b, &res);
}


///////////////////////////////////////////////////////////////////////////
/// Test cases taken from the netlib documentation at
/// https://www.netlib.org/lapack/lapacke.html#_calling_code_dgels_code
Expand Down Expand Up @@ -742,22 +741,22 @@ mod tests {
///////////////////////////////////////////////////////////////////////////
/// Testing error cases
///////////////////////////////////////////////////////////////////////////
use ndarray::ErrorKind;
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")
},
_ => panic!("Expected Err()")
Err(err) => match err {
LinalgError::Shape(shape_error) => {
assert_eq!(shape_error.kind(), ErrorKind::IncompatibleShape)
}
_ => panic!("Expected ShapeError"),
},
_ => panic!("Expected Err()"),
}
}

Expand All @@ -769,13 +768,13 @@ 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")
},
_ => panic!("Expected Err()")
Err(err) => match err {
LinalgError::Shape(shape_error) => {
assert_eq!(shape_error.kind(), ErrorKind::IncompatibleShape)
}
_ => panic!("Expected ShapeError"),
},
_ => panic!("Expected Err()"),
}
}
}

0 comments on commit def3ecc

Please sign in to comment.