datasketch_minhash_lsh/
error.rs1use std::{error, fmt};
2
3#[derive(Debug)]
4pub enum MinHashingError {
7 DifferentSeeds,
8 DifferentNumPermFuncs,
9 WrongThresholdInterval,
10 NumPermFuncsTooLow,
11 WrongWeightThreshold,
12 UnexpectedSumWeight,
13 KeyDoesNotExist,
14}
15
16impl fmt::Display for MinHashingError {
17 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
18 match *self {
19 MinHashingError::DifferentSeeds => write!(
20 f,
21 "computing jaccard similarity between minhashes only works if they \
22 use the same seed"
23 ),
24 MinHashingError::DifferentNumPermFuncs => write!(
25 f,
26 "computing jaccard similarity between minhashes only works if they \
27 use the same number of permutation functions"
28 ),
29 MinHashingError::WrongThresholdInterval => write!(f, "threshold must be in [0.0, 1.0]"),
30 MinHashingError::NumPermFuncsTooLow => write!(f, "Too few permutation functions"),
31 MinHashingError::WrongWeightThreshold => write!(f, "Weight must be in [0.0, 1.0]"),
32 MinHashingError::UnexpectedSumWeight => write!(f, "Weights must sum to 1.0"),
33 MinHashingError::KeyDoesNotExist => write!(f, "Attempted to remove a non-existing key"),
34 }
35 }
36}
37
38impl error::Error for MinHashingError {}