diff --git a/oars/Cargo.toml b/oars/Cargo.toml index 3baf9fb..a6e1b2e 100644 --- a/oars/Cargo.toml +++ b/oars/Cargo.toml @@ -19,7 +19,7 @@ rand = "0.8" primes = "0.3" itertools = "0.9" num = "0.3" -ndarray = "0.13.1" +ndarray = "0.14.0" serde = { version = "1.0", optional = true } serde_derive = { version = "1.0", optional = true } rayon = { version = "1.3", optional = true } diff --git a/oars/src/constructors/bose.rs b/oars/src/constructors/bose.rs index 5b8cfe3..bd71812 100644 --- a/oars/src/constructors/bose.rs +++ b/oars/src/constructors/bose.rs @@ -1,5 +1,5 @@ use crate::oa::{OAConstructor, OAResult, OA}; -use crate::utils::{ErrorKind, Integer, OarsError, OarsResult}; +use crate::utils::{Integer, OarsError, OarsResult}; use ndarray::Array2; use num::pow; use oars_proc_macro::Checked; @@ -12,7 +12,7 @@ use rayon::prelude::*; use crate::oa::ParOAConstructor; #[cfg(feature = "parallel")] -use ndarray::{stack, Axis}; +use ndarray::{concatenate, Axis}; impl BoseChecked { /// Check the parameters for Bose construction @@ -155,7 +155,7 @@ impl ParOAConstructor for Bose { % self.prime_base; }) }); - let points = stack![Axis(1), initial_points, points]; + let points: Array2 = concatenate(Axis(1), &[initial_points.view(), points.view()])?; Ok(OA { strength: T::from(2).unwrap(), levels: self.prime_base, diff --git a/oars/src/constructors/bush.rs b/oars/src/constructors/bush.rs index da92124..e95bd4d 100644 --- a/oars/src/constructors/bush.rs +++ b/oars/src/constructors/bush.rs @@ -1,5 +1,5 @@ use crate::oa::{OAConstructor, OAResult, OA}; -use crate::utils::{poly_eval, to_base_fixed, ErrorKind, Integer, OarsError, OarsResult}; +use crate::utils::{poly_eval, to_base_fixed, Integer, OarsError, OarsResult}; use ndarray::Array2; use num::pow::pow; use oars_proc_macro::Checked; @@ -10,7 +10,7 @@ use std::cmp::min; use crate::oa::ParOAConstructor; #[cfg(feature = "parallel")] -use ndarray::{parallel::prelude::*, stack, Axis}; +use ndarray::{concatenate, parallel::prelude::*, Axis}; #[cfg(feature = "parallel")] use rayon::iter::IntoParallelIterator; @@ -161,7 +161,7 @@ impl ParOAConstructor for Bush { col[[0 as usize; 0]] = T::from(row_idx - 1).unwrap() % self.prime_base; }) }); - let points = stack![Axis(1), initial_points, last_col]; + let points = concatenate(Axis(1), &[initial_points.view(), last_col.view()])?; return Ok(OA { strength: self.strength, diff --git a/oars/src/oa.rs b/oars/src/oa.rs index 7435f81..6c37e73 100644 --- a/oars/src/oa.rs +++ b/oars/src/oa.rs @@ -5,8 +5,8 @@ //! and can be extended by users to define new OA construction methods. use crate::perm_vec::PermutationVector; -use crate::utils::{ErrorKind, OarsError, OarsResult}; use crate::utils::{Float, Integer}; +use crate::utils::{OarsError, OarsResult}; use itertools::Itertools; use ndarray::Array2; use num::{pow, ToPrimitive}; diff --git a/oars/src/perm_vec.rs b/oars/src/perm_vec.rs index 9866290..05848e1 100644 --- a/oars/src/perm_vec.rs +++ b/oars/src/perm_vec.rs @@ -1,7 +1,6 @@ //! Provides an interface for a permutation vector class that makes it easy to //! randomly shuffle orthogonal arrays, or shuffle any set. -use rand; use rand::seq::SliceRandom; use std::ops::Index; diff --git a/oars/src/soa.rs b/oars/src/soa.rs index 56bc76e..c368b4e 100644 --- a/oars/src/soa.rs +++ b/oars/src/soa.rs @@ -7,12 +7,8 @@ use crate::utils::OarsError; use itertools::{zip, Itertools}; use ndarray::Array2; -use oars_proc_macro::Checked; use std::collections::{HashMap, HashSet}; -#[cfg(feature = "serialize")] -use serde_derive::{Deserialize, Serialize}; - /// A result type for strong orthogonal array construction pub type SOAResult = Result; diff --git a/oars/src/utils.rs b/oars/src/utils.rs index 652f7ae..d4bbd12 100644 --- a/oars/src/utils.rs +++ b/oars/src/utils.rs @@ -1,8 +1,6 @@ //! Misc utilities and convenience functions for the library use num::{self, NumCast}; -use std::error::Error; -use std::fmt; use std::vec::Vec; use thiserror::Error; @@ -93,6 +91,12 @@ pub enum ErrorKind { pub enum OarsError { #[error("Invalid params supplied to the constructor: {0}")] InvalidParams(String), + + #[error("There was an error pertaining to the shape of a matrix")] + ShapeError { + #[from] + source: ndarray::ShapeError, + }, } /// A generic type for anything that can return an `OarsError`.