Skip to content

Commit

Permalink
Fix compilation warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
jturner314 committed Feb 18, 2021
1 parent 48b63ee commit e223719
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 35 deletions.
1 change: 0 additions & 1 deletion blas-tests/tests/oper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use ndarray::linalg::general_mat_vec_mul;
use ndarray::prelude::*;
use ndarray::{Data, LinalgScalar};
use ndarray::{Ix, Ixs, SliceInfo, SliceOrIndex};
use std::iter::FromIterator;

use approx::{assert_abs_diff_eq, assert_relative_eq};
use defmac::defmac;
Expand Down
1 change: 0 additions & 1 deletion examples/life.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
)]

use ndarray::prelude::*;
use std::iter::FromIterator;

const INPUT: &[u8] = include_bytes!("life.txt");

Expand Down
3 changes: 1 addition & 2 deletions tests/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ use ndarray::indices;
use ndarray::prelude::*;
use ndarray::{arr3, rcarr2};
use ndarray::{Slice, SliceInfo, SliceOrIndex};
use std::iter::FromIterator;

macro_rules! assert_panics {
($body:expr) => {
Expand Down Expand Up @@ -1803,7 +1802,7 @@ fn test_contiguous() {
#[test]
fn test_contiguous_neg_strides() {
let s = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13];
let mut a = ArrayView::from_shape((2, 3, 2).strides((1, 4, 2)), &s).unwrap();
let a = ArrayView::from_shape((2, 3, 2).strides((1, 4, 2)), &s).unwrap();
assert_eq!(
a,
arr3(&[[[0, 2], [4, 6], [8, 10]], [[1, 3], [5, 7], [9, 11]]])
Expand Down
1 change: 0 additions & 1 deletion tests/azip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

use ndarray::prelude::*;
use ndarray::Zip;
use std::iter::FromIterator;

use itertools::{assert_equal, cloned};

Expand Down
3 changes: 2 additions & 1 deletion tests/dimension.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use defmac::defmac;

use ndarray::{arr2, ArcArray, Array, Axis, Dim, Dimension, IntoDimension, IxDyn, RemoveAxis};
use ndarray::{arr2, ArcArray, Array, Axis, Dim, Dimension, IxDyn, RemoveAxis};

use std::hash::{Hash, Hasher};

Expand Down Expand Up @@ -307,6 +307,7 @@ fn test_array_view() {
#[cfg(feature = "std")]
#[allow(clippy::cognitive_complexity)]
fn test_all_ndindex() {
use ndarray::IntoDimension;
macro_rules! ndindex {
($($i:expr),*) => {
for &rev in &[false, true] {
Expand Down
2 changes: 1 addition & 1 deletion tests/iterator_chunks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
)]

use ndarray::prelude::*;
use ndarray::NdProducer;

#[test]
#[cfg(feature = "std")]
fn chunks() {
use ndarray::NdProducer;
let a = <Array1<f32>>::linspace(1., 100., 10 * 10)
.into_shape((10, 10))
.unwrap();
Expand Down
45 changes: 22 additions & 23 deletions tests/iterators.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,9 @@
)]

use ndarray::prelude::*;
use ndarray::Ix;
use ndarray::{arr2, arr3, aview1, indices, s, Axis, Data, Dimension, Slice, Zip};
use ndarray::{arr3, aview1, indices, s, Axis, Slice, Zip};

use itertools::assert_equal;
use itertools::{enumerate, rev};
use std::iter::FromIterator;
use itertools::{assert_equal, enumerate};

macro_rules! assert_panics {
($body:expr) => {
Expand All @@ -37,7 +34,7 @@ fn double_ended() {
assert_eq!(it.next(), Some(1.));
assert_eq!(it.rev().last(), Some(2.));
assert_equal(aview1(&[1, 2, 3]), &[1, 2, 3]);
assert_equal(rev(aview1(&[1, 2, 3])), rev(&[1, 2, 3]));
assert_equal(aview1(&[1, 2, 3]).into_iter().rev(), [1, 2, 3].iter().rev());
}

#[test]
Expand All @@ -63,7 +60,7 @@ fn iter_size_hint() {
fn indexed() {
let a = ArcArray::linspace(0., 7., 8);
for (i, elt) in a.indexed_iter() {
assert_eq!(i, *elt as Ix);
assert_eq!(i, *elt as usize);
}
let a = a.reshape((2, 4, 1));
let (mut i, mut j, k) = (0, 0, 0);
Expand All @@ -78,22 +75,24 @@ fn indexed() {
}
}

fn assert_slice_correct<A, S, D>(v: &ArrayBase<S, D>)
where
S: Data<Elem = A>,
D: Dimension,
A: PartialEq + std::fmt::Debug,
{
let slc = v.as_slice();
assert!(slc.is_some());
let slc = slc.unwrap();
assert_eq!(v.len(), slc.len());
assert_equal(v.iter(), slc);
}

#[test]
#[cfg(feature = "std")]
fn as_slice() {
use ndarray::Data;

fn assert_slice_correct<A, S, D>(v: &ArrayBase<S, D>)
where
S: Data<Elem = A>,
D: Dimension,
A: PartialEq + std::fmt::Debug,
{
let slc = v.as_slice();
assert!(slc.is_some());
let slc = slc.unwrap();
assert_eq!(v.len(), slc.len());
assert_equal(v.iter(), slc);
}

let a = ArcArray::linspace(0., 7., 8);
let a = a.reshape((2, 4, 1));

Expand Down Expand Up @@ -544,9 +543,9 @@ fn axis_chunks_iter_corner_cases() {
assert_equal(
it,
vec![
arr2(&[[7.], [6.], [5.]]),
arr2(&[[4.], [3.], [2.]]),
arr2(&[[1.], [0.]]),
array![[7.], [6.], [5.]],
array![[4.], [3.], [2.]],
array![[1.], [0.]],
],
);

Expand Down
4 changes: 3 additions & 1 deletion tests/ixdyn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use ndarray::Array;
use ndarray::IntoDimension;
use ndarray::ShapeBuilder;
use ndarray::{Ix0, Ix1, Ix2, Ix3, IxDyn};
use ndarray::Ix3;

#[test]
fn test_ixdyn() {
Expand Down Expand Up @@ -157,6 +157,8 @@ fn test_0_add_broad() {
#[test]
#[cfg(feature = "std")]
fn test_into_dimension() {
use ndarray::{Ix0, Ix1, Ix2, IxDyn};

let a = Array::linspace(0., 41., 6 * 7).into_shape((6, 7)).unwrap();
let a2 = a.clone().into_shape(IxDyn(&[6, 7])).unwrap();
let b = a2.clone().into_dimensionality::<Ix2>().unwrap();
Expand Down
2 changes: 1 addition & 1 deletion tests/numeric.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ fn test_mean_with_array_of_floats() {

#[test]
fn sum_mean() {
let a = arr2(&[[1., 2.], [3., 4.]]);
let a: Array2<f64> = arr2(&[[1., 2.], [3., 4.]]);
assert_eq!(a.sum_axis(Axis(0)), arr1(&[4., 6.]));
assert_eq!(a.sum_axis(Axis(1)), arr1(&[3., 7.]));
assert_eq!(a.mean_axis(Axis(0)), Some(arr1(&[2., 3.])));
Expand Down
2 changes: 0 additions & 2 deletions tests/oper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@ use ndarray::{rcarr1, rcarr2};
use ndarray::{Data, LinalgScalar};
use ndarray::{Ix, Ixs};
use num_traits::Zero;
use std::iter::FromIterator;

use approx::assert_abs_diff_eq;
use defmac::defmac;
use std::ops::Neg;

fn test_oper(op: &str, a: &[f32], b: &[f32], c: &[f32]) {
let aa = rcarr1(a);
Expand Down
1 change: 0 additions & 1 deletion tests/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

use ndarray::prelude::*;
use ndarray::Zip;
use std::iter::FromIterator;

// Edge Cases for Windows iterator:
//
Expand Down

0 comments on commit e223719

Please sign in to comment.