pub mod prelude;
#[derive(Debug, Clone, PartialOrd, PartialEq)]
pub enum ArrayError {
BroadcastShapeMismatch,
ConcatenateShapeMismatch,
ShapeMustMatchValuesLength,
ShapesMustMatch {
shape_1: Vec<usize>,
shape_2: Vec<usize>,
},
SqueezeShapeOfAxisMustBeOne,
AxisOutOfBounds,
OutOfBounds {
value: &'static str,
},
ParameterError {
param: &'static str,
message: &'static str,
},
UnsupportedDimension {
supported: Vec<usize>,
},
MustBeUnique {
value: String,
},
MustBeEqual {
value1: String,
value2: String,
},
MustBeOneOf {
value1: String,
value2: String,
},
NotImplemented,
}
impl std::error::Error for ArrayError {}
impl std::fmt::Display for ArrayError {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
match self {
ArrayError::BroadcastShapeMismatch => write!(f, "Incompatible shapes for broadcasting"),
ArrayError::ConcatenateShapeMismatch => write!(f, "Incompatible shapes for concatenate"),
ArrayError::ShapeMustMatchValuesLength => write!(f, "Shape must match values length"),
ArrayError::ShapesMustMatch { shape_1, shape_2 } => write!(f, "Shapes of {shape_1:?} and {shape_2:?} must match"),
ArrayError::SqueezeShapeOfAxisMustBeOne => write!(f, "cannot select an axis to squeeze out which has size not equal to one"),
ArrayError::AxisOutOfBounds => write!(f, "`axis` is out of bounds for array"),
ArrayError::OutOfBounds { value } => write!(f, "`{value}` is out of bounds"),
ArrayError::ParameterError { param, message } => write!(f, "parameter error: `{param}`: {message}"),
ArrayError::UnsupportedDimension { supported } => write!(f, "supported dimensions are: {supported:?}"),
ArrayError::MustBeUnique { value } => write!(f, "`{value}` must be unique"),
ArrayError::MustBeEqual { value1, value2 } => write!(f, "`{value1}` and `{value2}` must be equal"),
ArrayError::MustBeOneOf { value1, value2 } => write!(f, "`{value1}` must be one of `{value2}`"),
ArrayError::NotImplemented => write!(f, "not implemented"),
}
}
}