Skip to content

Commit

Permalink
removed unnecessary tolerance from is_close
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasgeis committed Feb 1, 2023
1 parent da47da2 commit 3dd06d4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/distributions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ impl DiscreteDistribution {

/// Creates a new Distribution from a given list of proabilities
pub fn from_list(list: &Vec<Probability>) -> Self {
if !is_close(list.into_iter().sum::<Probability>(), 1.0, None)
if !is_close(list.into_iter().sum::<Probability>(), 1.0)
|| !list.into_iter().all(|p| 0.0 <= *p && *p <= 1.0)
{
return Self {
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ impl FromStr for Algorithm {
}

/// Are two f64 close enough to be considered the same
pub fn is_close(a: f64, b: f64, tol: Option<f64>) -> bool {
(b - a).abs() < tol.unwrap_or(1e-09)
pub fn is_close(a: f64, b: f64) -> bool {
(b - a).abs() < 1e-09
}

/// Get Factorial of Number
Expand Down

0 comments on commit 3dd06d4

Please sign in to comment.