From de4a067d27b01f6780c7b2a42b5efa3a9ea7dd23 Mon Sep 17 00:00:00 2001 From: Philippe Renon Date: Mon, 16 Nov 2020 12:11:24 +0100 Subject: [PATCH] clippy: fix len_zero warnings --- src/base/construction.rs | 4 ++-- src/base/norm.rs | 6 +++--- src/base/statistics.rs | 4 ++-- src/linalg/svd.rs | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/base/construction.rs b/src/base/construction.rs index ac6eed1e..7ac24306 100644 --- a/src/base/construction.rs +++ b/src/base/construction.rs @@ -195,7 +195,7 @@ where where SB: Storage, { - assert!(rows.len() > 0, "At least one row must be given."); + assert!(!rows.is_empty(), "At least one row must be given."); let nrows = R::try_to_usize().unwrap_or_else(|| rows.len()); let ncols = rows[0].len(); assert!( @@ -237,7 +237,7 @@ where where SB: Storage, { - assert!(columns.len() > 0, "At least one column must be given."); + assert!(!columns.is_empty(), "At least one column must be given."); let ncols = C::try_to_usize().unwrap_or(columns.len()); let nrows = columns[0].len(); assert!( diff --git a/src/base/norm.rs b/src/base/norm.rs index 07994b79..a7fa66e9 100644 --- a/src/base/norm.rs +++ b/src/base/norm.rs @@ -524,12 +524,12 @@ where match D::dim() { 1 => { - if vs.len() == 0 { + if vs.is_empty() { let _ = f(&Self::canonical_basis_element(0)); } } 2 => { - if vs.len() == 0 { + if vs.is_empty() { let _ = f(&Self::canonical_basis_element(0)) && f(&Self::canonical_basis_element(1)); } else if vs.len() == 1 { @@ -542,7 +542,7 @@ where // Otherwise, nothing. } 3 => { - if vs.len() == 0 { + if vs.is_empty() { let _ = f(&Self::canonical_basis_element(0)) && f(&Self::canonical_basis_element(1)) && f(&Self::canonical_basis_element(2)); diff --git a/src/base/statistics.rs b/src/base/statistics.rs index 37ca8d75..231f654b 100644 --- a/src/base/statistics.rs +++ b/src/base/statistics.rs @@ -199,7 +199,7 @@ impl> Matrix { where N: Field + SupersetOf, { - if self.len() == 0 { + if self.is_empty() { N::zero() } else { let val = self.iter().cloned().fold((N::zero(), N::zero()), |a, b| { @@ -308,7 +308,7 @@ impl> Matrix { where N: Field + SupersetOf, { - if self.len() == 0 { + if self.is_empty() { N::zero() } else { self.sum() / crate::convert(self.len() as f64) diff --git a/src/linalg/svd.rs b/src/linalg/svd.rs index 2e51dc85..1e942e69 100644 --- a/src/linalg/svd.rs +++ b/src/linalg/svd.rs @@ -108,7 +108,7 @@ where max_niter: usize, ) -> Option { assert!( - matrix.len() != 0, + !matrix.is_empty(), "Cannot compute the SVD of an empty matrix." ); let (nrows, ncols) = matrix.data.shape();