message: Explicitly implement ArgminRandom for types (ndarray)
diff: // http://opensource.org/licenses/MIT>, at your option. This file may not be
  // copied, modified, or distributed except according to those terms.
  -use crate::ArgminRandom;
  -use rand::distributions::uniform::SampleUniform;
  use rand::Rng;
  -impl<T> ArgminRandom for ndarray::Array1<T>
  -where
  - T: SampleUniform + std::cmp::PartialOrd + Clone,
  -{
  - fn rand_from_range(min: &Self, max: &Self) -> ndarray::Array1<T> {
  +use crate::ArgminRandom;
  +
  +macro_rules! make_random {
  + ($t:ty) => {
  + impl ArgminRandom for ndarray::Array1<$t> {
  + fn rand_from_range(min: &Self, max: &Self) -> ndarray::Array1<$t> {
  assert!(!min.is_empty());
  assert_eq!(min.len(), max.len());
  @@ -22,6 +21,8 @@ where
  ndarray::Array1::from_iter(min.iter().zip(max.iter()).map(|(a, b)| {
  // Do not require a < b:
  + // We do want to know if a and b are *exactly* the same.
  + #[allow(clippy::float_cmp)]
  if a == b {
  a.clone()
  } else if a < b {
  @@ -33,11 +34,8 @@ where
  }
  }
  -impl<T> ArgminRandom for ndarray::Array2<T>
  -where
  - T: SampleUniform + std::cmp::PartialOrd + Clone,
  -{
  - fn rand_from_range(min: &Self, max: &Self) -> ndarray::Array2<T> {
  + impl ArgminRandom for ndarray::Array2<$t> {
  + fn rand_from_range(min: &Self, max: &Self) -> ndarray::Array2<$t> {
  assert!(!min.is_empty());
  assert_eq!(min.raw_dim(), max.raw_dim());
  @@ -47,6 +45,8 @@ where
  let a = min.get((i, j)).unwrap();
  let b = max.get((i, j)).unwrap();
  + // We do want to know if a and b are *exactly* the same.
  + #[allow(clippy::float_cmp)]
  if a == b {
  a.clone()
  } else if a < b {
  @@ -57,3 +57,13 @@ where
  })
  }
  }
  + };
  +}
  +
  +make_random!(isize);
  +make_random!(i8);
  +make_random!(i16);
  +make_random!(i32);
  +make_random!(i64);
  +make_random!(f32);
  +make_random!(f64);
  