Skip to content

Commit f0542a9

Browse files
committedSep 9, 2020
fix or silence clippy lints in workspace
1 parent 9f07125 commit f0542a9

File tree

7 files changed

+44
-37
lines changed

7 files changed

+44
-37
lines changed
 

‎sprs-benches/src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ fn bench_densities() -> Result<(), Box<dyn std::error::Error>> {
164164
for spec in &bench_specs {
165165
let shape = spec.shape;
166166

167-
let is_shape_bench = spec.shapes.len() != 0;
167+
let is_shape_bench = !spec.shapes.is_empty();
168168
let densities = if is_shape_bench {
169169
spec.shapes
170170
.iter()

‎sprs-ldl/src/lib.rs

+20-13
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,16 @@ pub struct Ldl {
7878
fill_red_method: FillInReduction,
7979
}
8080

81+
impl Default for Ldl {
82+
fn default() -> Self {
83+
Self {
84+
check_symmetry: SymmetryCheck::CheckSymmetry,
85+
fill_red_method: FillInReduction::ReverseCuthillMcKee,
86+
check_perm: PermutationCheck::CheckPerm,
87+
}
88+
}
89+
}
90+
8191
/// Structure to compute and hold a symbolic LDLT decomposition
8292
#[derive(Debug, Clone)]
8393
pub struct LdlSymbolic<I> {
@@ -101,11 +111,7 @@ pub struct LdlNumeric<N, I> {
101111

102112
impl Ldl {
103113
pub fn new() -> Self {
104-
Self {
105-
check_symmetry: SymmetryCheck::CheckSymmetry,
106-
fill_red_method: FillInReduction::ReverseCuthillMcKee,
107-
check_perm: PermutationCheck::CheckPerm,
108-
}
114+
Self::default()
109115
}
110116

111117
pub fn check_symmetry(self, check: SymmetryCheck) -> Self {
@@ -257,10 +263,10 @@ impl<I: SpIndex> LdlSymbolic<I> {
257263

258264
LdlSymbolic {
259265
colptr: l_colptr,
260-
parents: parents,
266+
parents,
261267
nz: l_nz,
262-
flag_workspace: flag_workspace,
263-
perm: perm,
268+
flag_workspace,
269+
perm,
264270
}
265271
}
266272

@@ -294,11 +300,11 @@ impl<I: SpIndex> LdlSymbolic<I> {
294300
let pattern_workspace = DStack::with_capacity(n);
295301
let mut ldl_numeric = LdlNumeric {
296302
symbolic: self,
297-
l_indices: l_indices,
298-
l_data: l_data,
299-
diag: diag,
300-
y_workspace: y_workspace,
301-
pattern_workspace: pattern_workspace,
303+
l_indices,
304+
l_data,
305+
diag,
306+
y_workspace,
307+
pattern_workspace,
302308
};
303309
ldl_numeric.update(mat).map(|_| ldl_numeric)
304310
}
@@ -466,6 +472,7 @@ pub fn ldl_symbolic<N, I, PStorage>(
466472
/// Perform numeric LDLT decomposition
467473
///
468474
/// pattern_workspace is a DStack of capacity n
475+
#[allow(clippy::too_many_arguments)]
469476
pub fn ldl_numeric<N, I, PStorage>(
470477
mat: CsMatViewI<N, I>,
471478
l_colptr: &[I],

‎src/sparse/binop.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ pub fn csmat_binop<N, I, Iptr, F>(
8787
binop: F,
8888
) -> CsMatI<N, I, Iptr>
8989
where
90-
N: Num,
90+
N: Num + Clone,
9191
I: SpIndex,
9292
Iptr: SpIndex,
9393
F: Fn(&N, &N) -> N,
@@ -109,10 +109,7 @@ where
109109
// Sadly the vec! macro requires Clone, but we don't want to force
110110
// Clone on our consumers, so we have to use this workaround.
111111
// This should compile to decent code however.
112-
let mut out_data = Vec::with_capacity(max_nnz);
113-
for _ in 0..max_nnz {
114-
out_data.push(N::zero());
115-
}
112+
let mut out_data = vec![N::zero(); max_nnz];
116113

117114
let nnz = csmat_binop_same_storage_raw(
118115
lhs,

‎src/sparse/csmat.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -702,10 +702,7 @@ impl<N, I: SpIndex, Iptr: SpIndex>
702702
if outer_ind >= outer_dims {
703703
// we need to add a new outer dimension
704704
let last_nnz = *self.indptr.last().unwrap(); // indptr never empty
705-
self.indptr.reserve(1 + outer_ind - outer_dims);
706-
for _ in outer_dims..outer_ind {
707-
self.indptr.push(last_nnz);
708-
}
705+
self.indptr.resize(outer_ind + 1, last_nnz);
709706
self.set_outer_dims(outer_ind + 1);
710707
self.indptr.push(last_nnz + Iptr::one());
711708
self.indices.push(inner_ind_idx);
@@ -2996,14 +2993,15 @@ mod approx_impls {
29962993
} else {
29972994
// Checks if all elements in self has a matching element
29982995
// in other
2999-
if !self.iter().all(|(n, (i, j))| {
2996+
let all_matching = self.iter().all(|(n, (i, j))| {
30002997
n.abs_diff_eq(
30012998
other
30022999
.get(i.to_usize().unwrap(), j.to_usize().unwrap())
30033000
.unwrap_or(&N::zero()),
30043001
epsilon.clone(),
30053002
)
3006-
}) {
3003+
});
3004+
if !all_matching {
30073005
return false;
30083006
}
30093007

@@ -3055,15 +3053,16 @@ mod approx_impls {
30553053
} else {
30563054
// Checks if all elements in self has a matching element
30573055
// in other
3058-
if !self.iter().all(|(n, (i, j))| {
3056+
let all_matches = self.iter().all(|(n, (i, j))| {
30593057
n.ulps_eq(
30603058
other
30613059
.get(i.to_usize().unwrap(), j.to_usize().unwrap())
30623060
.unwrap_or(&N::zero()),
30633061
epsilon.clone(),
30643062
max_ulps,
30653063
)
3066-
}) {
3064+
});
3065+
if !all_matches {
30673066
return false;
30683067
}
30693068

@@ -3122,15 +3121,16 @@ mod approx_impls {
31223121
} else {
31233122
// Checks if all elements in self has a matching element
31243123
// in other
3125-
if !self.iter().all(|(n, (i, j))| {
3124+
let all_matches = self.iter().all(|(n, (i, j))| {
31263125
n.relative_eq(
31273126
other
31283127
.get(i.to_usize().unwrap(), j.to_usize().unwrap())
31293128
.unwrap_or(&N::zero()),
31303129
epsilon.clone(),
31313130
max_relative.clone(),
31323131
)
3133-
}) {
3132+
});
3133+
if !all_matches {
31343134
return false;
31353135
}
31363136

‎src/sparse/smmp.rs

+2
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ pub fn thread_threading_strategy() -> ThreadingStrategy {
7878
/// `a_indptr.last().unwrap() + b_indptr.last.unwrap()` in `c_indices`.
7979
/// Therefore, to prevent this function from allocating, it is required
8080
/// to have reserved at least this amount of memory.
81+
#[allow(clippy::too_many_arguments)]
8182
pub fn symbolic<Iptr: SpIndex, I: SpIndex>(
8283
a_indptr: &[Iptr],
8384
a_indices: &[I],
@@ -152,6 +153,7 @@ pub fn symbolic<Iptr: SpIndex, I: SpIndex>(
152153
/// (though some cases might go unnoticed).
153154
///
154155
/// The parts for the C matrix should come from the `symbolic` function.
156+
#[allow(clippy::too_many_arguments)]
155157
pub fn numeric<
156158
Iptr: SpIndex,
157159
I: SpIndex,

‎src/sparse/vec.rs

+1
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ pub trait SparseIterTools: Iterator {
183183
/// assert_eq!(nnz_zip.next(), Some((2, &2., &-2.)));
184184
/// assert_eq!(nnz_zip.next(), None);
185185
/// ```
186+
#[allow(clippy::type_complexity)]
186187
fn nnz_zip<'a, I, N1, N2>(
187188
self,
188189
other: I,

‎suitesparse_bindings/sprs_suitesparse_ldl/src/lib.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,9 @@ macro_rules! ldl_impl {
106106
lp: vec![0; n + 1],
107107
parent: vec![0; n],
108108
lnz: vec![0; n],
109-
flag: flag,
110-
p: p,
111-
pinv: pinv,
109+
flag,
110+
p,
111+
pinv,
112112
};
113113
unsafe {
114114
$symbolic(
@@ -162,11 +162,11 @@ macro_rules! ldl_impl {
162162
let pattern = vec![0; n];
163163
let mut ldl_numeric = $Numeric {
164164
symbolic: self,
165-
li: li,
166-
lx: lx,
167-
d: d,
168-
y: y,
169-
pattern: pattern,
165+
li,
166+
lx,
167+
d,
168+
y,
169+
pattern,
170170
};
171171
ldl_numeric.update(mat).map(|_| ldl_numeric)
172172
}

0 commit comments

Comments
 (0)
Please sign in to comment.