forked from M-Labs/nalgebra
clippy: fix len_zero warnings
This commit is contained in:
parent
d577a18a45
commit
de4a067d27
@ -195,7 +195,7 @@ where
|
|||||||
where
|
where
|
||||||
SB: Storage<N, U1, C>,
|
SB: Storage<N, U1, C>,
|
||||||
{
|
{
|
||||||
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 nrows = R::try_to_usize().unwrap_or_else(|| rows.len());
|
||||||
let ncols = rows[0].len();
|
let ncols = rows[0].len();
|
||||||
assert!(
|
assert!(
|
||||||
@ -237,7 +237,7 @@ where
|
|||||||
where
|
where
|
||||||
SB: Storage<N, R>,
|
SB: Storage<N, R>,
|
||||||
{
|
{
|
||||||
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 ncols = C::try_to_usize().unwrap_or(columns.len());
|
||||||
let nrows = columns[0].len();
|
let nrows = columns[0].len();
|
||||||
assert!(
|
assert!(
|
||||||
|
@ -524,12 +524,12 @@ where
|
|||||||
|
|
||||||
match D::dim() {
|
match D::dim() {
|
||||||
1 => {
|
1 => {
|
||||||
if vs.len() == 0 {
|
if vs.is_empty() {
|
||||||
let _ = f(&Self::canonical_basis_element(0));
|
let _ = f(&Self::canonical_basis_element(0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
2 => {
|
2 => {
|
||||||
if vs.len() == 0 {
|
if vs.is_empty() {
|
||||||
let _ = f(&Self::canonical_basis_element(0))
|
let _ = f(&Self::canonical_basis_element(0))
|
||||||
&& f(&Self::canonical_basis_element(1));
|
&& f(&Self::canonical_basis_element(1));
|
||||||
} else if vs.len() == 1 {
|
} else if vs.len() == 1 {
|
||||||
@ -542,7 +542,7 @@ where
|
|||||||
// Otherwise, nothing.
|
// Otherwise, nothing.
|
||||||
}
|
}
|
||||||
3 => {
|
3 => {
|
||||||
if vs.len() == 0 {
|
if vs.is_empty() {
|
||||||
let _ = f(&Self::canonical_basis_element(0))
|
let _ = f(&Self::canonical_basis_element(0))
|
||||||
&& f(&Self::canonical_basis_element(1))
|
&& f(&Self::canonical_basis_element(1))
|
||||||
&& f(&Self::canonical_basis_element(2));
|
&& f(&Self::canonical_basis_element(2));
|
||||||
|
@ -199,7 +199,7 @@ impl<N: Scalar, R: Dim, C: Dim, S: Storage<N, R, C>> Matrix<N, R, C, S> {
|
|||||||
where
|
where
|
||||||
N: Field + SupersetOf<f64>,
|
N: Field + SupersetOf<f64>,
|
||||||
{
|
{
|
||||||
if self.len() == 0 {
|
if self.is_empty() {
|
||||||
N::zero()
|
N::zero()
|
||||||
} else {
|
} else {
|
||||||
let val = self.iter().cloned().fold((N::zero(), N::zero()), |a, b| {
|
let val = self.iter().cloned().fold((N::zero(), N::zero()), |a, b| {
|
||||||
@ -308,7 +308,7 @@ impl<N: Scalar, R: Dim, C: Dim, S: Storage<N, R, C>> Matrix<N, R, C, S> {
|
|||||||
where
|
where
|
||||||
N: Field + SupersetOf<f64>,
|
N: Field + SupersetOf<f64>,
|
||||||
{
|
{
|
||||||
if self.len() == 0 {
|
if self.is_empty() {
|
||||||
N::zero()
|
N::zero()
|
||||||
} else {
|
} else {
|
||||||
self.sum() / crate::convert(self.len() as f64)
|
self.sum() / crate::convert(self.len() as f64)
|
||||||
|
@ -108,7 +108,7 @@ where
|
|||||||
max_niter: usize,
|
max_niter: usize,
|
||||||
) -> Option<Self> {
|
) -> Option<Self> {
|
||||||
assert!(
|
assert!(
|
||||||
matrix.len() != 0,
|
!matrix.is_empty(),
|
||||||
"Cannot compute the SVD of an empty matrix."
|
"Cannot compute the SVD of an empty matrix."
|
||||||
);
|
);
|
||||||
let (nrows, ncols) = matrix.data.shape();
|
let (nrows, ncols) = matrix.data.shape();
|
||||||
|
Loading…
Reference in New Issue
Block a user