27
27
//! ## Example
28
28
//! ```rust
29
29
//! use approx::AbsDiffEq; // for abs_diff_eq
30
- //! use ndarray::{Array1, Array2};
30
+ //! use ndarray::{array, Array1, Array2};
31
31
//! use ndarray_linalg::{LeastSquaresSvd, LeastSquaresSvdInto, LeastSquaresSvdInPlace};
32
32
//!
33
33
//! let a: Array2<f64> = array![
@@ -213,7 +213,7 @@ where
213
213
impl < E , D > LeastSquaresSvdInto < D , E , Ix1 > for ArrayBase < D , Ix2 >
214
214
where
215
215
E : Scalar + Lapack + LeastSquaresSvdDivideConquer_ ,
216
- D : DataMut < Elem = E > ,
216
+ D : DataMut < Elem = E > ,
217
217
{
218
218
/// Solve a least squares problem of the form `Ax = rhs`
219
219
/// by calling `A.least_squares(rhs)`, where `rhs` is a
@@ -239,7 +239,7 @@ where
239
239
impl < E , D > LeastSquaresSvdInto < D , E , Ix2 > for ArrayBase < D , Ix2 >
240
240
where
241
241
E : Scalar + Lapack + LeastSquaresSvdDivideConquer_ ,
242
- D : DataMut < Elem = E > ,
242
+ D : DataMut < Elem = E > ,
243
243
{
244
244
/// Solve a least squares problem of the form `Ax = rhs`
245
245
/// by calling `A.least_squares(rhs)`, where `rhs` is a
@@ -548,8 +548,8 @@ mod tests {
548
548
549
549
///////////////////////////////////////////////////////////////////////////
550
550
/// Test that the different lest squares traits work as intended on the
551
- /// different array types.
552
- ///
551
+ /// different array types.
552
+ ///
553
553
/// | least_squares | ls_into | ls_in_place |
554
554
/// --------------+---------------+---------+-------------+
555
555
/// Array | yes | yes | yes |
@@ -674,7 +674,6 @@ mod tests {
674
674
assert_result ( & a, & b, & res) ;
675
675
}
676
676
677
-
678
677
///////////////////////////////////////////////////////////////////////////
679
678
/// Test cases taken from the netlib documentation at
680
679
/// https://www.netlib.org/lapack/lapacke.html#_calling_code_dgels_code
@@ -742,22 +741,22 @@ mod tests {
742
741
///////////////////////////////////////////////////////////////////////////
743
742
/// Testing error cases
744
743
///////////////////////////////////////////////////////////////////////////
745
- use ndarray:: ErrorKind ;
746
744
use crate :: layout:: MatrixLayout ;
745
+ use ndarray:: ErrorKind ;
747
746
748
747
#[ test]
749
748
fn test_incompatible_shape_error_on_mismatching_num_rows ( ) {
750
749
let a: Array2 < f64 > = array ! [ [ 1. , 2. ] , [ 4. , 5. ] , [ 3. , 4. ] ] ;
751
750
let b: Array1 < f64 > = array ! [ 1. , 2. ] ;
752
751
let res = a. least_squares ( & b) ;
753
752
match res {
754
- Err ( err) =>
755
- match err {
756
- LinalgError :: Shape ( shape_error) =>
757
- assert_eq ! ( shape_error . kind ( ) , ErrorKind :: IncompatibleShape ) ,
758
- _ => panic ! ( "Expected ShapeError" )
759
- } ,
760
- _ => panic ! ( "Expected Err()" )
753
+ Err ( err) => match err {
754
+ LinalgError :: Shape ( shape_error ) => {
755
+ assert_eq ! ( shape_error. kind ( ) , ErrorKind :: IncompatibleShape )
756
+ }
757
+ _ => panic ! ( "Expected ShapeError" ) ,
758
+ } ,
759
+ _ => panic ! ( "Expected Err()" ) ,
761
760
}
762
761
}
763
762
@@ -769,13 +768,13 @@ mod tests {
769
768
770
769
let res = a. least_squares ( & b) ;
771
770
match res {
772
- Err ( err) =>
773
- match err {
774
- LinalgError :: Shape ( shape_error) =>
775
- assert_eq ! ( shape_error . kind ( ) , ErrorKind :: IncompatibleShape ) ,
776
- _ => panic ! ( "Expected ShapeError" )
777
- } ,
778
- _ => panic ! ( "Expected Err()" )
771
+ Err ( err) => match err {
772
+ LinalgError :: Shape ( shape_error ) => {
773
+ assert_eq ! ( shape_error. kind ( ) , ErrorKind :: IncompatibleShape )
774
+ }
775
+ _ => panic ! ( "Expected ShapeError" ) ,
776
+ } ,
777
+ _ => panic ! ( "Expected Err()" ) ,
779
778
}
780
779
}
781
780
}
0 commit comments