Skip to content

Commit 2ee6186

Browse files
authored
Merge pull request #321 from rust-ndarray/clippy-fix
clippy fix
2 parents 9414ba6 + 51b65d4 commit 2ee6186

File tree

10 files changed

+21
-24
lines changed

10 files changed

+21
-24
lines changed

lax/src/tridiagonal.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use std::ops::{Index, IndexMut};
1515
/// ... ..., u{n-1},
1616
/// 0, ..., l{n-1}, d{n-1},]
1717
/// ```
18-
#[derive(Clone, PartialEq)]
18+
#[derive(Clone, PartialEq, Eq)]
1919
pub struct Tridiagonal<A: Scalar> {
2020
/// layout of raw matrix
2121
pub l: MatrixLayout,

ndarray-linalg/examples/eig.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use ndarray_linalg::*;
33

44
fn main() {
55
let a = arr2(&[[2.0, 1.0, 2.0], [-2.0, 2.0, 1.0], [1.0, 2.0, -2.0]]);
6-
let (e, vecs) = a.clone().eig().unwrap();
6+
let (e, vecs) = a.eig().unwrap();
77
println!("eigenvalues = \n{:?}", e);
88
println!("V = \n{:?}", vecs);
99
let a_c: Array2<c64> = a.map(|f| c64::new(*f, 0.0));

ndarray-linalg/examples/eigh.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use ndarray_linalg::*;
66

77
fn main() {
88
let a = arr2(&[[3.0, 1.0, 1.0], [1.0, 3.0, 1.0], [1.0, 1.0, 3.0]]);
9-
let (e, vecs) = a.clone().eigh(UPLO::Upper).unwrap();
9+
let (e, vecs) = a.eigh(UPLO::Upper).unwrap();
1010
println!("eigenvalues = \n{:?}", e);
1111
println!("V = \n{:?}", vecs);
1212
let av = a.dot(&vecs);

ndarray-linalg/src/krylov/householder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ where
3434
{
3535
assert_eq!(w.len(), a.len());
3636
let n = a.len();
37-
let c = A::from(2.0).unwrap() * w.inner(&a);
37+
let c = A::from(2.0).unwrap() * w.inner(a);
3838
for l in 0..n {
3939
a[l] -= c * w[l];
4040
}

ndarray-linalg/src/krylov/mgs.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ impl<A: Scalar + Lapack> Orthogonalizer for MGS<A> {
5050
let mut coef = Array1::zeros(self.len() + 1);
5151
for i in 0..self.len() {
5252
let q = &self.q[i];
53-
let c = q.inner(&a);
53+
let c = q.inner(a);
5454
azip!((a in &mut *a, &q in q) *a -= c * q);
5555
coef[i] = c;
5656
}
@@ -77,12 +77,12 @@ impl<A: Scalar + Lapack> Orthogonalizer for MGS<A> {
7777
self.div_append(&mut a)
7878
}
7979

80-
fn div_append<S>(&mut self, mut a: &mut ArrayBase<S, Ix1>) -> AppendResult<A>
80+
fn div_append<S>(&mut self, a: &mut ArrayBase<S, Ix1>) -> AppendResult<A>
8181
where
8282
A: Lapack,
8383
S: DataMut<Elem = A>,
8484
{
85-
let coef = self.decompose(&mut a);
85+
let coef = self.decompose(a);
8686
let nrm = coef[coef.len() - 1].re();
8787
if nrm < self.tol {
8888
// Linearly dependent

ndarray-linalg/src/layout.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,8 @@ where
6767
}
6868

6969
fn as_allocated(&self) -> Result<&[A]> {
70-
Ok(self
71-
.as_slice_memory_order()
72-
.ok_or_else(|| LinalgError::MemoryNotCont)?)
70+
self.as_slice_memory_order()
71+
.ok_or(LinalgError::MemoryNotCont)
7372
}
7473
}
7574

@@ -78,8 +77,7 @@ where
7877
S: DataMut<Elem = A>,
7978
{
8079
fn as_allocated_mut(&mut self) -> Result<&mut [A]> {
81-
Ok(self
82-
.as_slice_memory_order_mut()
83-
.ok_or_else(|| LinalgError::MemoryNotCont)?)
80+
self.as_slice_memory_order_mut()
81+
.ok_or(LinalgError::MemoryNotCont)
8482
}
8583
}

ndarray-linalg/src/least_squares.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -304,12 +304,12 @@ where
304304
a.layout()?,
305305
a.as_allocated_mut()?,
306306
rhs.as_slice_memory_order_mut()
307-
.ok_or_else(|| LinalgError::MemoryNotCont)?,
307+
.ok_or(LinalgError::MemoryNotCont)?,
308308
)?;
309309

310310
let (m, n) = (a.shape()[0], a.shape()[1]);
311311
let solution = rhs.slice(s![0..n]).to_owned();
312-
let residual_sum_of_squares = compute_residual_scalar(m, n, rank, &rhs);
312+
let residual_sum_of_squares = compute_residual_scalar(m, n, rank, rhs);
313313
Ok(LeastSquaresResult {
314314
solution,
315315
singular_values: Array::from_shape_vec((singular_values.len(),), singular_values)?,
@@ -399,7 +399,7 @@ where
399399
let solution: Array2<E> = rhs.slice(s![..a.shape()[1], ..]).to_owned();
400400
let singular_values = Array::from_shape_vec((singular_values.len(),), singular_values)?;
401401
let (m, n) = (a.shape()[0], a.shape()[1]);
402-
let residual_sum_of_squares = compute_residual_array1(m, n, rank, &rhs);
402+
let residual_sum_of_squares = compute_residual_array1(m, n, rank, rhs);
403403
Ok(LeastSquaresResult {
404404
solution,
405405
singular_values,

ndarray-linalg/src/lobpcg/lobpcg.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,11 @@ fn apply_constraints<A: Scalar + Lapack>(
8383
let u = gram_yv
8484
.columns()
8585
.into_iter()
86-
.map(|x| {
86+
.flat_map(|x| {
8787
let res = cholesky_yy.solvec(&x).unwrap();
8888

8989
res.to_vec()
9090
})
91-
.flatten()
9291
.collect::<Vec<A>>();
9392

9493
let rows = gram_yv.len_of(Axis(0));

ndarray-linalg/src/lobpcg/svd.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ impl<A: Float + PartialOrd + DivAssign<A> + 'static + MagnitudeCorrection> Trunc
3030
let mut a = self.eigvals.iter().enumerate().collect::<Vec<_>>();
3131

3232
// sort by magnitude
33-
a.sort_by(|(_, x), (_, y)| x.partial_cmp(&y).unwrap().reverse());
33+
a.sort_by(|(_, x), (_, y)| x.partial_cmp(y).unwrap().reverse());
3434

3535
// calculate cut-off magnitude (borrowed from scipy)
3636
let cutoff = A::epsilon() * // float precision

ndarray-linalg/src/tridiagonal.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ where
272272
Sb: DataMut<Elem = A>,
273273
{
274274
A::solve_tridiagonal(
275-
&self,
275+
self,
276276
rhs.layout()?,
277277
Transpose::No,
278278
rhs.as_slice_mut().unwrap(),
@@ -287,7 +287,7 @@ where
287287
Sb: DataMut<Elem = A>,
288288
{
289289
A::solve_tridiagonal(
290-
&self,
290+
self,
291291
rhs.layout()?,
292292
Transpose::Transpose,
293293
rhs.as_slice_mut().unwrap(),
@@ -302,7 +302,7 @@ where
302302
Sb: DataMut<Elem = A>,
303303
{
304304
A::solve_tridiagonal(
305-
&self,
305+
self,
306306
rhs.layout()?,
307307
Transpose::Hermite,
308308
rhs.as_slice_mut().unwrap(),
@@ -622,7 +622,7 @@ where
622622
{
623623
fn det_tridiagonal(&self) -> Result<A> {
624624
let n = self.d.len();
625-
Ok(rec_rel(&self)[n])
625+
Ok(rec_rel(self)[n])
626626
}
627627
}
628628

@@ -671,7 +671,7 @@ where
671671
A: Scalar + Lapack,
672672
{
673673
fn rcond_tridiagonal(&self) -> Result<A::Real> {
674-
Ok(A::rcond_tridiagonal(&self)?)
674+
Ok(A::rcond_tridiagonal(self)?)
675675
}
676676
}
677677

0 commit comments

Comments
 (0)