tensorlogic_train/augmentation/
error.rs1#[derive(Debug, Clone)]
3pub enum AugmentationError {
4 InvalidProbability(f64),
6 InvalidAlpha(f64),
8 ShapeMismatch {
10 expected: Vec<usize>,
11 got: Vec<usize>,
12 },
13 EmptyInput,
15 InvalidNoise { std: f64 },
17 InvalidCrop { crop_size: usize, input_size: usize },
19}
20
21impl std::fmt::Display for AugmentationError {
22 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
23 match self {
24 AugmentationError::InvalidProbability(p) => {
25 write!(f, "probability {p} is outside [0, 1]")
26 }
27 AugmentationError::InvalidAlpha(a) => {
28 write!(f, "alpha {a} must be positive")
29 }
30 AugmentationError::ShapeMismatch { expected, got } => {
31 write!(f, "shape mismatch: expected {expected:?}, got {got:?}")
32 }
33 AugmentationError::EmptyInput => write!(f, "input array is empty"),
34 AugmentationError::InvalidNoise { std } => {
35 write!(f, "noise std {std} must be non-negative")
36 }
37 AugmentationError::InvalidCrop {
38 crop_size,
39 input_size,
40 } => {
41 write!(f, "crop size {crop_size} exceeds input size {input_size}")
42 }
43 }
44 }
45}
46
47impl std::error::Error for AugmentationError {}