Skip to content

Fixing CI errors #1226

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 10 commits into from
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- stable
- beta
- nightly
- 1.51.0 # MSRV
- 1.59.0 # MSRV

steps:
- uses: actions/checkout@v2
Expand Down
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
name = "ndarray"
version = "0.15.6"
edition = "2018"
rust-version = "1.51"
rust-version = "1.59"
authors = [
"Ulrik Sverdrup \"bluss\"",
"Jim Turner"
Expand Down Expand Up @@ -78,8 +78,8 @@ matrixmultiply-threading = ["matrixmultiply/threading"]
debug = true

[workspace]
members = ["ndarray-rand", "xtest-serialization", "xtest-blas"]
exclude = ["xtest-numeric"]
members = ["ndarray-rand", "xtest-serialization", "xtest-blas","xtest-numeric"]


[package.metadata.release]
no-dev-version = true
Expand Down
2 changes: 1 addition & 1 deletion examples/life.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,5 +90,5 @@ fn main() {
}
render(&a);
let alive = a.iter().filter(|&&x| x > 0).count();
println!("After {} steps there are {} cells alive", steps, alive);
println!("After {steps} steps there are {alive} cells alive");
}
2 changes: 1 addition & 1 deletion examples/type_conversion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,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: 2 additions & 2 deletions examples/zip_many.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ fn main() {
// and this is how to do the *same thing* with azip!()
azip!((a in &mut a, &b in &b, &c in c) *a = b + c);

println!("{:8.4}", a);
println!("{a:8.4}");

// sum of each row
let mut sums = Array::zeros(a.nrows());
Expand All @@ -44,5 +44,5 @@ fn main() {
Zip::from(a.exact_chunks(chunk_sz))
.and(&mut sums)
.for_each(|chunk, sum| *sum = chunk.sum());
println!("{:8.4}", sums);
println!("{sums:8.4}");
}
4 changes: 2 additions & 2 deletions src/array_serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ where
E: de::Error,
{
if v != ARRAY_FORMAT_VERSION {
let err_msg = format!("unknown array version: {}", v);
let err_msg = format!("unknown array version: {v}");
Err(de::Error::custom(err_msg))
} else {
Ok(())
Expand Down Expand Up @@ -193,7 +193,7 @@ impl<'de> Deserialize<'de> for ArrayField {
b"dim" => Ok(ArrayField::Dim),
b"data" => Ok(ArrayField::Data),
other => Err(de::Error::unknown_field(
&format!("{:?}", other),
&format!("{other:?}"),
ARRAY_FIELDS,
)),
}
Expand Down
32 changes: 15 additions & 17 deletions src/arrayformat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ where
shape => {
let blank_lines = "\n".repeat(shape.len() - 2);
let indent = " ".repeat(depth + 1);
let separator = format!(",\n{}{}", blank_lines, indent);
let separator = format!(",\n{blank_lines}{indent}");

f.write_str("[")?;
let limit = fmt_opt.collapse_limit(full_ndim - depth - 1);
Expand Down Expand Up @@ -220,7 +220,7 @@ where
self.view().layout(),
)?;
match D::NDIM {
Some(ndim) => write!(f, ", const ndim={}", ndim)?,
Some(ndim) => write!(f, ", const ndim={ndim}")?,
None => write!(f, ", dynamic ndim={}", self.ndim())?,
}
Ok(())
Expand Down Expand Up @@ -296,9 +296,7 @@ mod formatting_with_omit {
// use assert to avoid printing the strings twice on failure
assert!(
expected == actual,
"formatting assertion failed\nexpected:\n{}\nactual:\n{}\n",
expected,
actual,
"formatting assertion failed\nexpected:\n{}\nactual:\n{}\n",expected,actual
);
}

Expand Down Expand Up @@ -326,15 +324,15 @@ mod formatting_with_omit {
#[test]
fn empty_arrays() {
let a: Array2<u32> = arr2(&[[], []]);
let actual = format!("{}", a);
let actual = format!("{a}");
let expected = "[[]]";
assert_str_eq(expected, &actual);
}

#[test]
fn zero_length_axes() {
let a = Array3::<f32>::zeros((3, 0, 4));
let actual = format!("{}", a);
let actual = format!("{a}");
let expected = "[[[]]]";
assert_str_eq(expected, &actual);
}
Expand All @@ -343,7 +341,7 @@ mod formatting_with_omit {
fn dim_0() {
let element = 12;
let a = arr0(element);
let actual = format!("{}", a);
let actual = format!("{a}");
let expected = "12";
assert_str_eq(expected, &actual);
}
Expand All @@ -352,7 +350,7 @@ mod formatting_with_omit {
fn dim_1() {
let overflow: usize = 2;
let a = Array1::from_elem(ARRAY_MANY_ELEMENT_LIMIT + overflow, 1);
let actual = format!("{}", a);
let actual = format!("{a}");
let expected = format!("[{}]", ellipsize(AXIS_LIMIT_ROW, ", ", a.iter()));
assert_str_eq(&expected, &actual);
}
Expand All @@ -361,7 +359,7 @@ mod formatting_with_omit {
fn dim_1_alternate() {
let overflow: usize = 2;
let a = Array1::from_elem(ARRAY_MANY_ELEMENT_LIMIT + overflow, 1);
let actual = format!("{:#}", a);
let actual = format!("{a:#}");
let expected = format!("[{}]", a.iter().format(", "));
assert_str_eq(&expected, &actual);
}
Expand All @@ -373,7 +371,7 @@ mod formatting_with_omit {
(AXIS_2D_OVERFLOW_LIMIT, AXIS_2D_OVERFLOW_LIMIT + overflow),
1,
);
let actual = format!("{}", a);
let actual = format!("{a}");
let expected = "\
[[1, 1, 1, 1, 1, ..., 1, 1, 1, 1, 1],
[1, 1, 1, 1, 1, ..., 1, 1, 1, 1, 1],
Expand All @@ -392,7 +390,7 @@ mod formatting_with_omit {
#[test]
fn dim_2_non_last_axis_overflow() {
let a = Array2::from_elem((ARRAY_MANY_ELEMENT_LIMIT / 10, 10), 1);
let actual = format!("{}", a);
let actual = format!("{a}");
let row = format!("{}", a.row(0));
let expected = format!(
"[{}]",
Expand All @@ -404,7 +402,7 @@ mod formatting_with_omit {
#[test]
fn dim_2_non_last_axis_overflow_alternate() {
let a = Array2::from_elem((AXIS_LIMIT_COL * 4, 6), 1);
let actual = format!("{:#}", a);
let actual = format!("{a:#}");
let row = format!("{}", a.row(0));
let expected = format!("[{}]", (0..a.nrows()).map(|_| &row).format(",\n "));
assert_str_eq(&expected, &actual);
Expand All @@ -420,7 +418,7 @@ mod formatting_with_omit {
),
1,
);
let actual = format!("{}", a);
let actual = format!("{a}");
let row = format!("[{}]", ellipsize(AXIS_LIMIT_ROW, ", ", a.row(0)));
let expected = format!(
"[{}]",
Expand All @@ -439,7 +437,7 @@ mod formatting_with_omit {
),
1,
);
let actual = format!("{:#}", a);
let actual = format!("{a:#}");
let row = format!("{}", a.row(0));
let expected = format!("[{}]", (0..a.nrows()).map(|_| &row).format(",\n "));
assert_str_eq(&expected, &actual);
Expand All @@ -453,7 +451,7 @@ mod formatting_with_omit {
1000. + (100. * ((i as f64).sqrt() + (j as f64).sin() + k as f64)).round() / 100.
},
);
let actual = format!("{:6.1}", a);
let actual = format!("{a:6.1}");
let expected = "\
[[[1000.0, 1001.0, 1002.0, 1003.0, 1004.0, ..., 1007.0, 1008.0, 1009.0, 1010.0, 1011.0],
[1000.8, 1001.8, 1002.8, 1003.8, 1004.8, ..., 1007.8, 1008.8, 1009.8, 1010.8, 1011.8],
Expand Down Expand Up @@ -534,7 +532,7 @@ mod formatting_with_omit {
#[test]
fn dim_4_overflow_outer() {
let a = Array4::from_shape_fn((10, 10, 3, 3), |(i, j, k, l)| i + j + k + l);
let actual = format!("{:2}", a);
let actual = format!("{a:2}");
// Generated using NumPy with:
// np.set_printoptions(threshold=500, edgeitems=3)
// np.fromfunction(lambda i, j, k, l: i + j + k + l, (10, 10, 3, 3), dtype=int)
Expand Down
2 changes: 1 addition & 1 deletion src/dimension/broadcast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,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
6 changes: 3 additions & 3 deletions src/dimension/dimension_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ pub trait Dimension:

/// Compute the size of the dimension (number of elements)
fn size(&self) -> usize {
self.slice().iter().fold(1, |s, &a| s * a as usize)
self.slice().iter().product()
}

/// Compute the size while checking for overflow.
Expand Down Expand Up @@ -603,7 +603,7 @@ impl Dimension for Dim<[Ix; 2]> {
fn size_checked(&self) -> Option<usize> {
let m = get!(self, 0);
let n = get!(self, 1);
(m as usize).checked_mul(n as usize)
m.checked_mul(n)
}

#[inline]
Expand Down Expand Up @@ -728,7 +728,7 @@ impl Dimension for Dim<[Ix; 3]> {
let m = get!(self, 0);
let n = get!(self, 1);
let o = get!(self, 2);
m as usize * n as usize * o as usize
m * n * o
}

#[inline]
Expand Down
2 changes: 1 addition & 1 deletion src/dimension/dynindeximpl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ impl<T: PartialEq> PartialEq for IxDynRepr<T> {
match (self, rhs) {
(&IxDynRepr::Inline(slen, ref sarr), &IxDynRepr::Inline(rlen, ref rarr)) => {
slen == rlen
&& (0..CAP as usize)
&& (0..CAP)
.filter(|&i| i < slen as usize)
.all(|i| sarr[i] == rarr[i])
}
Expand Down
8 changes: 4 additions & 4 deletions src/dimension/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ mod sequence;
/// Calculate offset from `Ix` stride converting sign properly
#[inline(always)]
pub fn stride_offset(n: Ix, stride: Ix) -> isize {
(n as isize) * ((stride as Ixs) as isize)
(n as isize) * (stride as Ixs)
}

/// Check whether the given `dim` and `stride` lead to overlapping indices
Expand Down Expand Up @@ -463,7 +463,7 @@ pub fn do_slice(dim: &mut usize, stride: &mut usize, slice: Slice) -> isize {
} else {
let d = m / abs_step;
let r = m % abs_step;
d + if r > 0 { 1 } else { 0 }
d + (r>0) as usize
};

// Update stride. The additional check is necessary to avoid possible
Expand Down Expand Up @@ -729,12 +729,12 @@ where
let merged_len = into_len * take_len;
if take_len <= 1 {
dim.set_axis(into, merged_len);
dim.set_axis(take, if merged_len == 0 { 0 } else { 1 });
dim.set_axis(take, (merged_len != 0) as usize);
true
} else if into_len <= 1 {
strides.set_axis(into, take_stride as usize);
dim.set_axis(into, merged_len);
dim.set_axis(take, if merged_len == 0 { 0 } else { 1 });
dim.set_axis(take, (merged_len != 0) as usize);
true
} else if take_stride == into_len as isize * into_stride {
dim.set_axis(into, merged_len);
Expand Down
2 changes: 1 addition & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ impl fmt::Display for ShapeError {

impl fmt::Debug for ShapeError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self)
write!(f, "{self}")
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/impl_methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1990,7 +1990,7 @@ where
let strides = unlimited_transmute::<D, D2>(self.strides);
return Ok(ArrayBase::from_data_ptr(self.data, self.ptr)
.with_strides_dim(strides, dim));
} else if D::NDIM == None || D2::NDIM == None { // one is dynamic dim
} else if D::NDIM.is_none() || D2::NDIM.is_none() { // one is dynamic dim
// safe because dim, strides are equivalent under a different type
if let Some(dim) = D2::from_dimension(&self.dim) {
if let Some(strides) = D2::from_dimension(&self.strides) {
Expand Down
4 changes: 2 additions & 2 deletions src/indexes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ where
.slice()
.iter()
.zip(ix.slice().iter())
.fold(0, |s, (&a, &b)| s + a as usize * b as usize);
.fold(0, |s, (&a, &b)| s + a * b);
self.dim.size() - gone
}
};
Expand Down Expand Up @@ -286,7 +286,7 @@ where
.slice()
.iter()
.zip(self.index.slice().iter())
.fold(0, |s, (&a, &b)| s + a as usize * b as usize);
.fold(0, |s, (&a, &b)| s + a * b);
let l = self.dim.size() - gone;
(l, Some(l))
}
Expand Down
2 changes: 1 addition & 1 deletion src/iterators/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ impl<A, D: Dimension> ExactSizeIterator for Baseiter<A, D> {
.slice()
.iter()
.zip(ix.slice().iter())
.fold(0, |s, (&a, &b)| s + a as usize * b as usize);
.fold(0, |s, (&a, &b)| s + a * b);
self.dim.size() - gone
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/layout/layoutfmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ impl fmt::Debug for Layout {
} else {
(0..32).filter(|&i| self.is(1 << i)).try_fold((), |_, i| {
if let Some(name) = LAYOUT_NAMES.get(i) {
write!(f, "{}", name)
write!(f, "{name}")
} else {
write!(f, "{:#x}", i)
write!(f, "{i:#x}")
}
})?;
};
Expand Down
8 changes: 4 additions & 4 deletions src/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,17 +149,17 @@ impl SliceInfoElem {
impl fmt::Display for SliceInfoElem {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match *self {
SliceInfoElem::Index(index) => write!(f, "{}", index)?,
SliceInfoElem::Index(index) => write!(f, "{index}")?,
SliceInfoElem::Slice { start, end, step } => {
if start != 0 {
write!(f, "{}", start)?;
write!(f, "{start}")?;
}
write!(f, "..")?;
if let Some(i) = end {
write!(f, "{}", i)?;
write!(f, "{i}")?;
}
if step != 1 {
write!(f, ";{}", step)?;
write!(f, ";{step}")?;
}
}
SliceInfoElem::NewAxis => write!(f, stringify!(NewAxis))?,
Expand Down
Loading