Skip to content

Commit f0173a8

Browse files
committed
even more
1 parent 0ed84b5 commit f0173a8

22 files changed

+73
-44
lines changed

benches/bench1.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@ fn iadd_scalar_2d_strided_dyn(bench: &mut test::Bencher) {
589589
fn scaled_add_2d_f32_regular(bench: &mut test::Bencher) {
590590
let mut av = Array::<f32, _>::zeros((ADD2DSZ, ADD2DSZ));
591591
let bv = Array::<f32, _>::zeros((ADD2DSZ, ADD2DSZ));
592-
let scalar = std::f32::consts::Pi;
592+
let scalar = std::f32::consts::PI;
593593
bench.iter(|| {
594594
av.scaled_add(scalar, &bv);
595595
});

examples/axis_ops.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
#![allow(
2+
clippy::many_single_char_names,
3+
clippy::deref_addrof,
4+
clippy::unreadable_literal,
5+
clippy::many_single_char_names
6+
)]
17
extern crate ndarray;
28

39
use ndarray::prelude::*;

examples/bounds_check_elim.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
#![crate_type = "lib"]
2+
#![allow(
3+
clippy::many_single_char_names,
4+
clippy::deref_addrof,
5+
clippy::unreadable_literal,
6+
clippy::many_single_char_names
7+
)]
28

39
// Test cases for bounds check elimination
410

examples/convo.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ where
2828
for i in 0..n - 2 {
2929
for j in 0..m - 2 {
3030
let mut conv = F::zero();
31+
#[allow(clippy::needless_range_loop)]
3132
for k in 0..3 {
3233
for l in 0..3 {
3334
conv = conv + *a.uget((i + k, j + l)) * kernel[k][l];

examples/life.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ extern crate ndarray;
88

99
use ndarray::prelude::*;
1010

11-
const INPUT: &'static [u8] = include_bytes!("life.txt");
11+
const INPUT: &[u8] = include_bytes!("life.txt");
1212
//const INPUT: &'static [u8] = include_bytes!("lifelite.txt");
1313

1414
const N: usize = 100;
@@ -77,7 +77,7 @@ fn render(a: &Board) {
7777
print!(".");
7878
}
7979
}
80-
println!("");
80+
println!();
8181
}
8282
}
8383

examples/zip_many.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
1+
#![allow(
2+
clippy::many_single_char_names,
3+
clippy::deref_addrof,
4+
clippy::unreadable_literal,
5+
clippy::many_single_char_names
6+
)]
17
extern crate ndarray;
28

9+
310
use ndarray::prelude::*;
411
use ndarray::Zip;
512

src/dimension/dimension_trait.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ macro_rules! impl_insert_axis_array(
367367
debug_assert!(axis.index() <= $n);
368368
let mut out = [1; $n + 1];
369369
out[0..axis.index()].copy_from_slice(&self.slice()[0..axis.index()]);
370-
out[axis.index()+1..$n+1].copy_from_slice(&self.slice()[axis.index()..$n]);
370+
out[axis.index()+1..=$n].copy_from_slice(&self.slice()[axis.index()..$n]);
371371
Dim(out)
372372
}
373373
);

src/dimension/dynindeximpl.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ impl IxDyn {
221221
/// Create a new dimension value with `n` axes, all zeros
222222
#[inline]
223223
pub fn zeros(n: usize) -> IxDyn {
224-
const ZEROS: &'static [usize] = &[0; 4];
224+
const ZEROS: &[usize] = &[0; 4];
225225
if n <= ZEROS.len() {
226226
Dim(&ZEROS[..n])
227227
} else {

src/geomspace.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ where
9696
Some(Geomspace {
9797
sign: a.signum(),
9898
start: log_a,
99-
step: step,
99+
step,
100100
index: 0,
101101
len: n,
102102
})

src/impl_clone.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ impl<S: RawDataClone, D: Clone> Clone for ArrayBase<S, D> {
1313
unsafe {
1414
let (data, ptr) = self.data.clone_with_ptr(self.ptr);
1515
ArrayBase {
16-
data: data,
17-
ptr: ptr,
16+
data,
17+
ptr,
1818
dim: self.dim.clone(),
1919
strides: self.strides.clone(),
2020
}

src/impl_constructors.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -422,8 +422,8 @@ where
422422
ArrayBase {
423423
ptr: v.as_mut_ptr(),
424424
data: DataOwned::new(v),
425-
strides: strides,
426-
dim: dim,
425+
strides,
426+
dim,
427427
}
428428
}
429429

src/impl_methods.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ where
5252
}
5353

5454
/// Return whether the array has any elements
55+
// #[allow(clippy::)]
5556
pub fn is_empty(&self) -> bool {
5657
self.len() == 0
5758
}
@@ -225,7 +226,7 @@ where
225226
{
226227
let data = self.data.into_shared();
227228
ArrayBase {
228-
data: data,
229+
data,
229230
ptr: self.ptr,
230231
dim: self.dim,
231232
strides: self.strides,
@@ -1196,7 +1197,7 @@ where
11961197
pub fn is_standard_layout(&self) -> bool {
11971198
fn is_standard_layout<D: Dimension>(dim: &D, strides: &D) -> bool {
11981199
if let Some(1) = D::NDIM {
1199-
return strides[0] == 1 || dim[0] <= 1
1200+
return strides[0] == 1 || dim[0] <= 1;
12001201
}
12011202
if dim.slice().iter().any(|&d| d == 0) {
12021203
return true;
@@ -1452,8 +1453,8 @@ where
14521453
return Ok(ArrayBase {
14531454
data: self.data,
14541455
ptr: self.ptr,
1455-
dim: dim,
1456-
strides: strides,
1456+
dim,
1457+
strides,
14571458
});
14581459
}
14591460
}

src/iterators/chunks.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ impl<'a, A, D: Dimension> ExactChunks<'a, A, D> {
6464

6565
ExactChunks {
6666
base: a,
67-
chunk: chunk,
68-
inner_strides: inner_strides,
67+
chunk,
68+
inner_strides,
6969
}
7070
}
7171
}
@@ -154,8 +154,8 @@ impl<'a, A, D: Dimension> ExactChunksMut<'a, A, D> {
154154

155155
ExactChunksMut {
156156
base: a,
157-
chunk: chunk,
158-
inner_strides: inner_strides,
157+
chunk,
158+
inner_strides,
159159
}
160160
}
161161
}

src/iterators/mod.rs

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ impl<A, D: Dimension> Baseiter<A, D> {
4545
#[inline]
4646
pub unsafe fn new(ptr: *mut A, len: D, stride: D) -> Baseiter<A, D> {
4747
Baseiter {
48-
ptr: ptr,
48+
ptr,
4949
index: len.first_index(),
5050
dim: len,
5151
strides: stride,
@@ -79,8 +79,7 @@ impl<A, D: Dimension> Iterator for Baseiter<A, D> {
7979
let ndim = self.dim.ndim();
8080
debug_assert_ne!(ndim, 0);
8181
let mut accum = init;
82-
loop {
83-
if let Some(mut index) = self.index.clone() {
82+
while let Some(mut index) = self.index.clone() {
8483
let stride = self.strides.last_elem() as isize;
8584
let elem_index = index.last_elem();
8685
let len = self.dim.last_elem();
@@ -93,10 +92,7 @@ impl<A, D: Dimension> Iterator for Baseiter<A, D> {
9392
}
9493
index.set_last_elem(len - 1);
9594
self.index = self.dim.next_for(index);
96-
} else {
97-
break;
98-
};
99-
}
95+
};
10096
accum
10197
}
10298
}
@@ -280,7 +276,7 @@ where
280276
pub(crate) fn new(self_: ArrayViewMut<'a, A, D>) -> Self {
281277
IterMut {
282278
inner: match self_.into_slice_() {
283-
Ok(x) => ElementsRepr::Slice(x.into_iter()),
279+
Ok(x) => ElementsRepr::Slice(x.iter_mut()),
284280
Err(self_) => ElementsRepr::Counted(self_.into_elements_base()),
285281
},
286282
}
@@ -776,7 +772,7 @@ impl<A, D: Dimension> AxisIterCore<A, D> {
776772
AxisIterCore {
777773
index: 0,
778774
len: shape,
779-
stride: stride,
775+
stride,
780776
inner_dim: v.dim.remove_axis(axis),
781777
inner_strides: v.strides.remove_axis(axis),
782778
ptr: v.ptr,
@@ -1198,8 +1194,8 @@ fn chunk_iter_parts<A, D: Dimension>(
11981194
let iter = AxisIterCore {
11991195
index: 0,
12001196
len: iter_len,
1201-
stride: stride,
1202-
inner_dim: inner_dim,
1197+
stride,
1198+
inner_dim,
12031199
inner_strides: v.strides,
12041200
ptr: v.ptr,
12051201
};
@@ -1211,9 +1207,9 @@ impl<'a, A, D: Dimension> AxisChunksIter<'a, A, D> {
12111207
pub(crate) fn new(v: ArrayView<'a, A, D>, axis: Axis, size: usize) -> Self {
12121208
let (iter, n_whole_chunks, last_dim) = chunk_iter_parts(v, axis, size);
12131209
AxisChunksIter {
1214-
iter: iter,
1215-
n_whole_chunks: n_whole_chunks,
1216-
last_dim: last_dim,
1210+
iter,
1211+
n_whole_chunks,
1212+
last_dim,
12171213
life: PhantomData,
12181214
}
12191215
}
@@ -1306,9 +1302,9 @@ impl<'a, A, D: Dimension> AxisChunksIterMut<'a, A, D> {
13061302
pub(crate) fn new(v: ArrayViewMut<'a, A, D>, axis: Axis, size: usize) -> Self {
13071303
let (iter, len, last_dim) = chunk_iter_parts(v.into_view(), axis, size);
13081304
AxisChunksIterMut {
1309-
iter: iter,
1305+
iter,
13101306
n_whole_chunks: len,
1311-
last_dim: last_dim,
1307+
last_dim,
13121308
life: PhantomData,
13131309
}
13141310
}

src/iterators/windows.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ impl<'a, A, D: Dimension> Windows<'a, A, D> {
4242
unsafe {
4343
Windows {
4444
base: ArrayView::from_shape_ptr(size.clone().strides(a.strides), a.ptr),
45-
window: window,
45+
window,
4646
strides: window_strides,
4747
}
4848
}

src/linalg/impl_linalg.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ where
7878
let mut sum = A::zero();
7979
for i in 0..self.len() {
8080
unsafe {
81-
sum = sum.clone() + self.uget(i).clone() * rhs.uget(i).clone();
81+
sum = sum + self.uget(i).clone() * rhs.uget(i).clone();
8282
}
8383
}
8484
sum
@@ -512,7 +512,7 @@ fn mat_mul_general<A>(
512512
}
513513
} else {
514514
// It's a no-op if `c` has zero length.
515-
if c.len() == 0 {
515+
if c.is_empty() {
516516
return;
517517
}
518518

src/linspace.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ where
8282
};
8383
Linspace {
8484
start: a,
85-
step: step,
85+
step,
8686
index: 0,
8787
len: n,
8888
}
@@ -106,7 +106,7 @@ where
106106
let steps = F::ceil(len / step);
107107
Linspace {
108108
start: a,
109-
step: step,
109+
step,
110110
len: steps.to_usize().expect(
111111
"Converting the length to `usize` must not fail. The most likely \
112112
cause of this failure is if the sign of `end - start` is \

src/logspace.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ where
9090
sign: base.signum(),
9191
base: base.abs(),
9292
start: a,
93-
step: step,
93+
step,
9494
index: 0,
9595
len: n,
9696
}

src/slice.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -316,8 +316,8 @@ where
316316
#[doc(hidden)]
317317
pub unsafe fn new_unchecked(indices: T, out_dim: PhantomData<D>) -> SliceInfo<T, D> {
318318
SliceInfo {
319-
out_dim: out_dim,
320-
indices: indices,
319+
out_dim,
320+
indices,
321321
}
322322
}
323323
}
@@ -338,7 +338,7 @@ where
338338
}
339339
Ok(SliceInfo {
340340
out_dim: PhantomData,
341-
indices: indices,
341+
indices,
342342
})
343343
}
344344
}

src/stacking.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ where
3737
A: Copy,
3838
D: RemoveAxis,
3939
{
40-
if arrays.len() == 0 {
40+
if arrays.is_empty() {
4141
return Err(from_kind(ErrorKind::Unsupported));
4242
}
4343
let mut res_dim = arrays[0].raw_dim();

tests/azip.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
#![allow(
2+
clippy::many_single_char_names,
3+
clippy::deref_addrof,
4+
clippy::unreadable_literal,
5+
clippy::many_single_char_names
6+
)]
17
extern crate itertools;
28
extern crate ndarray;
39

tests/iterator_chunks.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
#![allow(
2+
clippy::many_single_char_names,
3+
clippy::deref_addrof,
4+
clippy::unreadable_literal,
5+
clippy::many_single_char_names
6+
)]
17
extern crate ndarray;
28

39
use ndarray::prelude::*;

0 commit comments

Comments
 (0)