Skip to content

Commit

Permalink
Fix typos and deprecation warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
vks committed Dec 17, 2023
1 parent ec86c36 commit 34a0dbb
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/histogram.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ macro_rules! define_histogram_inner {

/// Define a histogram with a number of bins known at compile time.
///
/// Because macros are not hygenic for items, everything is defined in a private
/// Because macros are not hygienic for items, everything is defined in a private
/// module with the given name. This includes the `Histogram` struct, the number
/// of bins `LEN` and the histogram iterator `HistogramIter`.
///
Expand Down
6 changes: 3 additions & 3 deletions src/histogram_const.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ where
pub fn variance(&self, bin: usize) -> f64 {
let count = self.bins()[bin];
let sum: u64 = self.bins().iter().sum();
multinomal_variance(count as f64, 1. / (sum as f64))
multinomial_variance(count as f64, 1. / (sum as f64))
}

/// Return an iterator over the bins normalized by the bin widths.
Expand Down Expand Up @@ -291,7 +291,7 @@ where

/// Calculate the multinomial variance. Relevant for histograms.
#[inline(always)]
fn multinomal_variance(n: f64, n_tot_inv: f64) -> f64 {
fn multinomial_variance(n: f64, n_tot_inv: f64) -> f64 {
n * (1. - n * n_tot_inv)
}

Expand Down Expand Up @@ -380,6 +380,6 @@ where
fn next(&mut self) -> Option<f64> {
self.histogram_iter
.next()
.map(|(_, n)| multinomal_variance(n as f64, self.sum_inv))
.map(|(_, n)| multinomial_variance(n as f64, self.sum_inv))
}
}
4 changes: 2 additions & 2 deletions src/minmax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub struct Min {
}

impl Min {
/// Create a new minium estimator from a given value.
/// Create a new minimum estimator from a given value.
#[inline]
pub fn from_value(x: f64) -> Min {
Min { x }
Expand Down Expand Up @@ -115,7 +115,7 @@ pub struct Max {
}

impl Max {
/// Create a new maxium estimator from a given value.
/// Create a new maximum estimator from a given value.
#[inline]
pub fn from_value(x: f64) -> Max {
Max { x }
Expand Down
10 changes: 5 additions & 5 deletions tests/integration/histogram.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ fn iter() {

#[test]
fn normalized_bins() {
let inf = std::f64::INFINITY;
let inf = f64::INFINITY;
let mut h = Histogram10::from_ranges(
[-inf, 0.1, 0.2, 0.3, 0.4, 0.4, 0.7, 0.8, 0.9, 1.0, inf]
.iter()
Expand All @@ -83,7 +83,7 @@ fn normalized_bins() {

#[test]
fn widths() {
let inf = std::f64::INFINITY;
let inf = f64::INFINITY;
let h = Histogram10::from_ranges(
[-inf, 0.1, 0.2, 0.3, 0.4, 0.4, 0.7, 0.8, 0.9, 1.0, inf]
.iter()
Expand All @@ -99,7 +99,7 @@ fn widths() {

#[test]
fn centers() {
let inf = std::f64::INFINITY;
let inf = f64::INFINITY;
let h = Histogram10::from_ranges(
[-inf, 0.1, 0.2, 0.3, 0.4, 0.4, 0.7, 0.8, 0.9, 1.0, inf]
.iter()
Expand All @@ -115,7 +115,7 @@ fn centers() {

#[test]
fn from_ranges_infinity() {
let inf = std::f64::INFINITY;
let inf = f64::INFINITY;
let mut h = Histogram10::from_ranges(
[-inf, -0.4, -0.3, -0.2, -0.1, 0.0, 0.1, 0.2, 0.3, 0.4, inf]
.iter()
Expand All @@ -137,7 +137,7 @@ fn from_ranges_invalid() {
let valid = vec![0., 0.1, 0.2, 0.3, 0.4, 0.5, 0.7, 0.8, 0.9, 1.0, 2.0];
assert!(Histogram10::from_ranges(valid.iter().cloned()).is_ok());
let mut invalid_nan = valid.clone();
invalid_nan[3] = std::f64::NAN;
invalid_nan[3] = f64::NAN;
assert_eq!(
Histogram10::from_ranges(invalid_nan.iter().cloned()).unwrap_err(),
InvalidRangeError::NaN
Expand Down

0 comments on commit 34a0dbb

Please sign in to comment.