Skip to content

Commit

Permalink
afnan/ndarray 0.14.0 (#10)
Browse files Browse the repository at this point in the history
* --wip--

* Update to ndarray 0.14

* Address some breaking changes in the upstream API
* Clean up unused code indicated by `clippy`
  • Loading branch information
afnanenayet authored Dec 27, 2020
1 parent 8bf0992 commit 5676789
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 15 deletions.
2 changes: 1 addition & 1 deletion oars/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
6 changes: 3 additions & 3 deletions oars/src/constructors/bose.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -12,7 +12,7 @@ use rayon::prelude::*;
use crate::oa::ParOAConstructor;

#[cfg(feature = "parallel")]
use ndarray::{stack, Axis};
use ndarray::{concatenate, Axis};

impl<T: Integer> BoseChecked<T> {
/// Check the parameters for Bose construction
Expand Down Expand Up @@ -155,7 +155,7 @@ impl<T: Integer> ParOAConstructor<T> for Bose<T> {
% self.prime_base;
})
});
let points = stack![Axis(1), initial_points, points];
let points: Array2<T> = concatenate(Axis(1), &[initial_points.view(), points.view()])?;
Ok(OA {
strength: T::from(2).unwrap(),
levels: self.prime_base,
Expand Down
6 changes: 3 additions & 3 deletions oars/src/constructors/bush.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -161,7 +161,7 @@ impl<T: Integer> ParOAConstructor<T> for Bush<T> {
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,
Expand Down
2 changes: 1 addition & 1 deletion oars/src/oa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
1 change: 0 additions & 1 deletion oars/src/perm_vec.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
4 changes: 0 additions & 4 deletions oars/src/soa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<SOA, OarsError>;

Expand Down
8 changes: 6 additions & 2 deletions oars/src/utils.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -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`.
Expand Down

0 comments on commit 5676789

Please sign in to comment.