Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions benches/bench1.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#![feature(test)]
#![allow(unused_imports)]
#![allow(
clippy::many_single_char_names, clippy::deref_addrof, clippy::unreadable_literal, clippy::many_single_char_names
)]
#![allow(clippy::many_single_char_names, clippy::deref_addrof, clippy::unreadable_literal)]

extern crate test;

Expand Down
4 changes: 1 addition & 3 deletions benches/construct.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#![feature(test)]
#![allow(
clippy::many_single_char_names, clippy::deref_addrof, clippy::unreadable_literal, clippy::many_single_char_names
)]
#![allow(clippy::many_single_char_names, clippy::deref_addrof, clippy::unreadable_literal)]
extern crate test;
use test::Bencher;

Expand Down
4 changes: 1 addition & 3 deletions benches/gemv_gemm.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#![feature(test)]
#![allow(
clippy::many_single_char_names, clippy::deref_addrof, clippy::unreadable_literal, clippy::many_single_char_names
)]
#![allow(clippy::many_single_char_names, clippy::deref_addrof, clippy::unreadable_literal)]

extern crate test;
use test::Bencher;
Expand Down
4 changes: 1 addition & 3 deletions benches/higher-order.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#![feature(test)]
#![allow(
clippy::many_single_char_names, clippy::deref_addrof, clippy::unreadable_literal, clippy::many_single_char_names
)]
#![allow(clippy::many_single_char_names, clippy::deref_addrof, clippy::unreadable_literal)]
extern crate test;
use test::black_box;
use test::Bencher;
Expand Down
6 changes: 2 additions & 4 deletions benches/iter.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#![feature(test)]
#![allow(
clippy::many_single_char_names, clippy::deref_addrof, clippy::unreadable_literal, clippy::many_single_char_names
)]
#![allow(clippy::many_single_char_names, clippy::deref_addrof, clippy::unreadable_literal)]

extern crate test;
use rawpointer::PointerExt;
Expand Down Expand Up @@ -416,7 +414,7 @@ fn iter_axis_chunks_5_iter_sum(bench: &mut Bencher)

pub fn zip_mut_with(data: &Array3<f32>, out: &mut Array3<f32>)
{
out.zip_mut_with(&data, |o, &i| {
out.zip_mut_with(data, |o, &i| {
*o = i;
});
}
Expand Down
4 changes: 2 additions & 2 deletions benches/par_rayon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ fn fastexp(x: f64) -> f64
fn map_fastexp_regular(bench: &mut Bencher)
{
let mut a = Array2::<f64>::zeros((FASTEXP, FASTEXP));
bench.iter(|| a.mapv_inplace(|x| fastexp(x)));
bench.iter(|| a.mapv_inplace(fastexp));
}

#[bench]
Expand All @@ -72,7 +72,7 @@ fn map_fastexp_cut(bench: &mut Bencher)
{
let mut a = Array2::<f64>::zeros((FASTEXP, FASTEXP));
let mut a = a.slice_mut(s![.., ..-1]);
bench.iter(|| a.mapv_inplace(|x| fastexp(x)));
bench.iter(|| a.mapv_inplace(fastexp));
}

#[bench]
Expand Down
4 changes: 1 addition & 3 deletions examples/axis_ops.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#![allow(
clippy::many_single_char_names, clippy::deref_addrof, clippy::unreadable_literal, clippy::many_single_char_names
)]
#![allow(clippy::many_single_char_names, clippy::deref_addrof, clippy::unreadable_literal)]

use ndarray::prelude::*;

Expand Down
5 changes: 1 addition & 4 deletions examples/bounds_check_elim.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#![crate_type = "lib"]
#![allow(
clippy::many_single_char_names, clippy::deref_addrof, clippy::unreadable_literal, clippy::many_single_char_names
)]
#![allow(clippy::many_single_char_names, clippy::deref_addrof, clippy::unreadable_literal)]

// Test cases for bounds check elimination

Expand Down Expand Up @@ -57,7 +55,6 @@ pub fn test1d_single_mut(a: &mut Array1<f64>, i: usize) -> f64
#[no_mangle]
pub fn test1d_len_of(a: &Array1<f64>) -> f64
{
let a = a;
let mut sum = 0.;
for i in 0..a.len_of(Axis(0)) {
sum += a[i];
Expand Down
4 changes: 2 additions & 2 deletions examples/functions_and_traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ fn takes_base<S: Data, D>(arr: &ArrayBase<S, D>)

// We can also pass it to functions that accept `RawRef` and `LayoutRef`
// in the usual two ways:
takes_rawref(&arr);
takes_layout(&arr);
takes_rawref(arr);
takes_layout(arr);
//
takes_rawref_asref(&arr);
takes_layout_asref(&arr);
Expand Down
4 changes: 1 addition & 3 deletions examples/life.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#![allow(
clippy::many_single_char_names, clippy::deref_addrof, clippy::unreadable_literal, clippy::many_single_char_names
)]
#![allow(clippy::many_single_char_names, clippy::deref_addrof, clippy::unreadable_literal)]

use ndarray::prelude::*;

Expand Down
2 changes: 1 addition & 1 deletion examples/type_conversion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ fn main()
// can be guaranteed to be lossless at compile time. This is the safest
// approach.
let a_u8: Array<u8, _> = array![[1, 2, 3], [4, 5, 6]];
let a_f32 = a_u8.mapv(|element| f32::from(element));
let a_f32 = a_u8.mapv(f32::from);
assert_abs_diff_eq!(a_f32, array![[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]]);

// Fallible, lossless conversion with `TryFrom`
Expand Down
4 changes: 1 addition & 3 deletions examples/zip_many.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#![allow(
clippy::many_single_char_names, clippy::deref_addrof, clippy::unreadable_literal, clippy::many_single_char_names
)]
#![allow(clippy::many_single_char_names, clippy::deref_addrof, clippy::unreadable_literal)]

use ndarray::prelude::*;
use ndarray::Zip;
Expand Down
2 changes: 1 addition & 1 deletion ndarray-rand/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ fn sampling_works(a: &Array2<f64>, strategy: SamplingStrategy, axis: Axis, n_sam
// Check if, when sliced along `axis`, there is at least one lane in `a` equal to `b`
fn is_subset(a: &Array2<f64>, b: &ArrayView1<f64>, axis: Axis) -> bool
{
a.axis_iter(axis).any(|lane| &lane == b)
a.axis_iter(axis).any(|lane| lane == b)
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion src/dimension/broadcast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ mod tests
D1: Dimension + DimMax<D2>,
D2: Dimension,
{
let d = co_broadcast::<D1, D2, <D1 as DimMax<D2>>::Output>(&d1, d2);
let d = co_broadcast::<D1, D2, <D1 as DimMax<D2>>::Output>(d1, d2);
assert_eq!(d, r);
}
test_co(&Dim([2, 3]), &Dim([4, 1, 3]), Ok(Dim([4, 2, 3])));
Expand Down
8 changes: 4 additions & 4 deletions src/dimension/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -850,17 +850,17 @@ mod test
#[test]
fn max_abs_offset_check_overflow_examples()
{
let dim = (1, ::std::isize::MAX as usize, 1).into_dimension();
let dim = (1, isize::MAX as usize, 1).into_dimension();
let strides = (1, 1, 1).into_dimension();
max_abs_offset_check_overflow::<u8, _>(&dim, &strides).unwrap();
let dim = (1, ::std::isize::MAX as usize, 2).into_dimension();
let dim = (1, isize::MAX as usize, 2).into_dimension();
let strides = (1, 1, 1).into_dimension();
max_abs_offset_check_overflow::<u8, _>(&dim, &strides).unwrap_err();
let dim = (0, 2, 2).into_dimension();
let strides = (1, ::std::isize::MAX as usize, 1).into_dimension();
let strides = (1, isize::MAX as usize, 1).into_dimension();
max_abs_offset_check_overflow::<u8, _>(&dim, &strides).unwrap_err();
let dim = (0, 2, 2).into_dimension();
let strides = (1, ::std::isize::MAX as usize / 4, 1).into_dimension();
let strides = (1, isize::MAX as usize / 4, 1).into_dimension();
max_abs_offset_check_overflow::<i32, _>(&dim, &strides).unwrap_err();
}

Expand Down
6 changes: 3 additions & 3 deletions src/linalg/impl_linalg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -435,12 +435,12 @@ where A: LinalgScalar
{
let cblas_layout = c_layout.to_cblas_layout();
let a_trans = a_layout.to_cblas_transpose_for(cblas_layout);
let lda = blas_stride(&a, a_layout);
let lda = blas_stride(a, a_layout);

let b_trans = b_layout.to_cblas_transpose_for(cblas_layout);
let ldb = blas_stride(&b, b_layout);
let ldb = blas_stride(b, b_layout);

let ldc = blas_stride(&c, c_layout);
let ldc = blas_stride(c, c_layout);

macro_rules! gemm_scalar_cast {
(f32, $var:ident) => {
Expand Down
2 changes: 0 additions & 2 deletions src/tri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,6 @@ where
#[cfg(test)]
mod tests
{
use core::isize;

use crate::{array, dimension, Array0, Array1, Array2, Array3, ShapeBuilder};
use alloc::vec;

Expand Down
8 changes: 4 additions & 4 deletions tests/append.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,14 +255,14 @@ fn append_array_3d()
let aa = array![[[51, 52], [53, 54]], [[55, 56], [57, 58]]];
let av = aa.view();
println!("Send {:?} to append", av);
a.append(Axis(0), av.clone()).unwrap();
a.append(Axis(0), av).unwrap();

a.swap_axes(0, 1);
let aa = array![[[71, 72], [73, 74]], [[75, 76], [77, 78]]];
let mut av = aa.view();
av.swap_axes(0, 1);
println!("Send {:?} to append", av);
a.append(Axis(1), av.clone()).unwrap();
a.append(Axis(1), av).unwrap();
println!("{:?}", a);
let aa = array![[[81, 82], [83, 84]], [[85, 86], [87, 88]]];
let mut av = aa.view();
Expand Down Expand Up @@ -304,7 +304,7 @@ fn test_append_2d()
println!("{:?}", a);
assert_eq!(a.shape(), &[8, 4]);
for (i, row) in a.rows().into_iter().enumerate() {
let ones = i < 3 || i >= 5;
let ones = !(3..5).contains(&i);
assert!(row.iter().all(|&x| x == ones as i32 as f64), "failed on lane {}", i);
}

Expand All @@ -319,7 +319,7 @@ fn test_append_2d()
assert_eq!(a.shape(), &[4, 8]);

for (i, row) in a.columns().into_iter().enumerate() {
let ones = i < 3 || i >= 5;
let ones = !(3..5).contains(&i);
assert!(row.iter().all(|&x| x == ones as i32 as f64), "failed on lane {}", i);
}
}
Expand Down
4 changes: 1 addition & 3 deletions tests/array-construct.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#![allow(
clippy::many_single_char_names, clippy::deref_addrof, clippy::unreadable_literal, clippy::many_single_char_names
)]
#![allow(clippy::many_single_char_names, clippy::deref_addrof, clippy::unreadable_literal)]

use defmac::defmac;
use ndarray::arr3;
Expand Down
13 changes: 6 additions & 7 deletions tests/array.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#![allow(non_snake_case)]
#![allow(
clippy::many_single_char_names, clippy::deref_addrof, clippy::unreadable_literal, clippy::many_single_char_names,
clippy::float_cmp
clippy::many_single_char_names, clippy::deref_addrof, clippy::unreadable_literal, clippy::float_cmp
)]

use approx::assert_relative_eq;
Expand Down Expand Up @@ -1006,7 +1005,7 @@ fn iter_size_hint()
fn zero_axes()
{
let mut a = arr1::<f32>(&[]);
for _ in a.iter() {
if let Some(_) = a.iter().next() {
panic!();
}
a.map(|_| panic!());
Expand Down Expand Up @@ -1112,12 +1111,12 @@ fn as_slice_memory_order_mut_contiguous_cowarray()
#[test]
fn to_slice_memory_order()
{
for shape in vec![[2, 0, 3, 5], [2, 1, 3, 5], [2, 4, 3, 5]] {
for shape in [[2, 0, 3, 5], [2, 1, 3, 5], [2, 4, 3, 5]] {
let data: Vec<usize> = (0..shape.iter().product()).collect();
let mut orig = Array1::from(data.clone())
.into_shape_with_order(shape)
.unwrap();
for perm in vec![[0, 1, 2, 3], [0, 2, 1, 3], [2, 0, 1, 3]] {
for perm in [[0, 1, 2, 3], [0, 2, 1, 3], [2, 0, 1, 3]] {
let mut a = orig.view_mut().permuted_axes(perm);
assert_eq!(a.as_slice_memory_order().unwrap(), &data);
assert_eq!(a.as_slice_memory_order_mut().unwrap(), &data);
Expand Down Expand Up @@ -2173,7 +2172,7 @@ fn test_contiguous_neg_strides()
assert_eq!(f, arr3(&[[[11], [9]], [[10], [8]]]));
assert!(f.as_slice_memory_order().is_some());

let mut g = b.clone();
let mut g = b;
g.collapse_axis(Axis(1), 0);
assert_eq!(g, arr3(&[[[11, 7, 3]], [[10, 6, 2]]]));
assert!(g.as_slice_memory_order().is_none());
Expand Down Expand Up @@ -2568,7 +2567,7 @@ mod array_cow_tests

fn run_with_various_layouts(mut f: impl FnMut(Array2<i32>))
{
for all in vec![
for all in [
Array2::from_shape_vec((7, 8), (0..7 * 8).collect()).unwrap(),
Array2::from_shape_vec((7, 8).f(), (0..7 * 8).collect()).unwrap(),
] {
Expand Down
13 changes: 3 additions & 10 deletions tests/azip.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#![allow(
clippy::many_single_char_names, clippy::deref_addrof, clippy::unreadable_literal, clippy::many_single_char_names,
clippy::float_cmp
clippy::many_single_char_names, clippy::deref_addrof, clippy::unreadable_literal, clippy::float_cmp
)]

use ndarray::prelude::*;
Expand Down Expand Up @@ -138,17 +137,11 @@ fn test_zip_collect_drop()
{
fn a_is_f(self) -> bool
{
match self {
Config::CC | Config::CF => false,
_ => true,
}
!matches!(self, Config::CC | Config::CF)
}
fn b_is_f(self) -> bool
{
match self {
Config::CC => false,
_ => true,
}
!matches!(self, Config::CC)
}
}

Expand Down
3 changes: 1 addition & 2 deletions tests/into-ixdyn.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#![allow(
clippy::many_single_char_names, clippy::deref_addrof, clippy::unreadable_literal, clippy::many_single_char_names,
clippy::float_cmp
clippy::many_single_char_names, clippy::deref_addrof, clippy::unreadable_literal, clippy::float_cmp
)]

use ndarray::prelude::*;
Expand Down
3 changes: 1 addition & 2 deletions tests/iterator_chunks.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#![allow(
clippy::many_single_char_names, clippy::deref_addrof, clippy::unreadable_literal, clippy::many_single_char_names,
clippy::float_cmp
clippy::many_single_char_names, clippy::deref_addrof, clippy::unreadable_literal, clippy::float_cmp
)]

use ndarray::prelude::*;
Expand Down
6 changes: 3 additions & 3 deletions tests/iterators.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ fn double_ended()
assert_eq!(it.next(), Some(0));
assert_eq!(it.next_back(), Some(7));
assert_eq!(it.next(), Some(1));
assert_eq!(it.rev().last(), Some(2));
assert_eq!(it.rev().next_back(), Some(2));
assert_equal(aview1(&[1, 2, 3]), &[1, 2, 3]);
assert_equal(aview1(&[1, 2, 3]).into_iter().rev(), [1, 2, 3].iter().rev());
}
Expand Down Expand Up @@ -1058,7 +1058,7 @@ fn test_impl_iter_compiles()
// Requires that the iterators are covariant in the element type

// base case: std
fn slice_iter_non_empty_indices<'s, 'a>(array: &'a Vec<&'s str>) -> impl Iterator<Item = usize> + 'a
fn slice_iter_non_empty_indices<'a>(array: &'a Vec<&str>) -> impl Iterator<Item = usize> + 'a
{
array
.iter()
Expand All @@ -1070,7 +1070,7 @@ fn test_impl_iter_compiles()
let _ = slice_iter_non_empty_indices;

// ndarray case
fn array_iter_non_empty_indices<'s, 'a>(array: &'a Array<&'s str, Ix1>) -> impl Iterator<Item = usize> + 'a
fn array_iter_non_empty_indices<'a>(array: &'a Array<&str, Ix1>) -> impl Iterator<Item = usize> + 'a
{
array
.iter()
Expand Down
3 changes: 1 addition & 2 deletions tests/ix0.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#![allow(
clippy::many_single_char_names, clippy::deref_addrof, clippy::unreadable_literal, clippy::many_single_char_names,
clippy::float_cmp
clippy::many_single_char_names, clippy::deref_addrof, clippy::unreadable_literal, clippy::float_cmp
)]

use ndarray::Array;
Expand Down
3 changes: 1 addition & 2 deletions tests/ixdyn.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#![allow(
clippy::many_single_char_names, clippy::deref_addrof, clippy::unreadable_literal, clippy::many_single_char_names,
clippy::float_cmp
clippy::many_single_char_names, clippy::deref_addrof, clippy::unreadable_literal, clippy::float_cmp
)]

use ndarray::Array;
Expand Down
Loading