Squashed 'vendor/ruvector/' content from commit b64c2172
git-subtree-dir: vendor/ruvector git-subtree-split: b64c21726f2bb37286d9ee36a7869fef60cc6900
This commit is contained in:
42
crates/ruvector-hyperbolic-hnsw/src/error.rs
Normal file
42
crates/ruvector-hyperbolic-hnsw/src/error.rs
Normal file
@@ -0,0 +1,42 @@
|
||||
//! Error types for hyperbolic HNSW operations
|
||||
|
||||
use thiserror::Error;
|
||||
|
||||
/// Errors that can occur during hyperbolic operations
|
||||
#[derive(Error, Debug, Clone)]
|
||||
pub enum HyperbolicError {
|
||||
/// Vector is outside the Poincaré ball
|
||||
#[error("Vector norm {norm} exceeds ball radius (1/sqrt(c) - eps) for curvature c={curvature}")]
|
||||
OutsideBall { norm: f32, curvature: f32 },
|
||||
|
||||
/// Invalid curvature parameter
|
||||
#[error("Invalid curvature: {0}. Must be positive.")]
|
||||
InvalidCurvature(f32),
|
||||
|
||||
/// Dimension mismatch between vectors
|
||||
#[error("Dimension mismatch: expected {expected}, got {got}")]
|
||||
DimensionMismatch { expected: usize, got: usize },
|
||||
|
||||
/// Numerical instability detected
|
||||
#[error("Numerical instability: {0}")]
|
||||
NumericalInstability(String),
|
||||
|
||||
/// Shard not found
|
||||
#[error("Shard not found: {0}")]
|
||||
ShardNotFound(String),
|
||||
|
||||
/// Index out of bounds
|
||||
#[error("Index {index} out of bounds for size {size}")]
|
||||
IndexOutOfBounds { index: usize, size: usize },
|
||||
|
||||
/// Empty collection
|
||||
#[error("Cannot perform operation on empty collection")]
|
||||
EmptyCollection,
|
||||
|
||||
/// Search failed
|
||||
#[error("Search failed: {0}")]
|
||||
SearchFailed(String),
|
||||
}
|
||||
|
||||
/// Result type for hyperbolic operations
|
||||
pub type HyperbolicResult<T> = Result<T, HyperbolicError>;
|
||||
Reference in New Issue
Block a user