Skip to content

Commit

Permalink
Clean up SOA module
Browse files Browse the repository at this point in the history
* Use the universal error types that are used in the `oa` module
* Derive the checked version of the structs
* Remove `SOAConstructionError` and `SOAResult` (breaking change)
  • Loading branch information
afnanenayet committed Jul 24, 2019
1 parent f40dc15 commit bcd4646
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 26 deletions.
2 changes: 1 addition & 1 deletion oars/src/prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
#[cfg(feature = "parallel")]
pub use crate::oa::ParOAConstructor;
pub use crate::oa::{OAConstructor, OAResult, OA};
pub use crate::soa::{SOAConstructionError, SOAConstructor, SOAResult, SOA};
pub use crate::soa::{SOAConstructor, SOAResult, SOA};
pub use crate::utils::{Float, Integer, OarsError, OarsResult};
29 changes: 4 additions & 25 deletions oars/src/soa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,15 @@
use itertools::{zip, Itertools};
use ndarray::Array2;
use crate::utils::OarsError;
use std::collections::{HashMap, HashSet};
use oars_proc_macro::Checked;

#[cfg(feature = "serialize")]
use serde_derive::{Deserialize, Serialize};

/// The general categories of errors for `SOAConstructionError`
#[derive(Debug)]
#[cfg_attr(feature = "serialize", derive(Serialize, Deserialize))]
pub enum SOACErrorKind {
/// Invalid parameters were supplied to the constructor
InvalidParams,

/// There was a runtime error that prevented the strong orthogonal array from being properly
/// constructed
RuntimeError,
}

/// An error indicating that there was some error constructing the strong orthogonal array.
#[derive(Debug)]
pub struct SOAConstructionError {
/// The general category of the error
error_type: SOACErrorKind,

/// A user-friendly description of the array which can supply additional information about
/// the error.
desc: String,
}

/// A result type for strong orthogonal array construction
pub type SOAResult = Result<SOA, SOAConstructionError>;
pub type SOAResult = Result<SOA, OarsError>;

/// A trait that demarcates SOA constructors
pub trait SOAConstructor {
Expand All @@ -46,7 +25,7 @@ pub trait SOAConstructor {

/// A structure representing a strong orthogonal array, consisting of the array and associated
/// metadata.
#[derive(Debug)]
#[derive(Debug, Checked)]
pub struct SOA {
/// The strength of the strong orthogonal array
pub strength: u32,
Expand Down

0 comments on commit bcd4646

Please sign in to comment.