pub struct Uniform<T = f64> { /* private fields */ }
Expand description
An axis with equal sized bins.
An axis with N equally spaced, equal sized, bins between [low, high). Below (above) this range is an underflow (overflow) bin. Hence this axis has N+2 bins.
For floating point types, positive and negative infinities map to overflow and underflow bins respectively. NaN maps to the overflow bin.
§Example
Create a 1D histogram with 10 uniform bins between -5.0 and 5.0, plus overflow and underflow bins.
use ndhistogram::{ndhistogram, Histogram};
use ndhistogram::axis::{Axis, Uniform, BinInterval};
let hist = ndhistogram!(Uniform::new(10, -5.0, 5.0)?);
let axis = &hist.axes().as_tuple().0;
assert_eq!(axis.bin(0), Some(BinInterval::underflow(-5.0)));
assert_eq!(axis.bin(1), Some(BinInterval::new(-5.0, -4.0)));
assert_eq!(axis.bin(11), Some(BinInterval::overflow(5.0)));
Implementations§
Source§impl<T> Uniform<T>
impl<T> Uniform<T>
Sourcepub fn new(num: usize, low: T, high: T) -> Result<Self, AxisError>where
T: Float,
pub fn new(num: usize, low: T, high: T) -> Result<Self, AxisError>where
T: Float,
Factory method to create an axis with num uniformly spaced bins in the range [low, high). Under/overflow bins cover values outside this range.
Only implemented for Float. Use Uniform::with_step_size for integers.
Sourcepub fn with_step_size(num: usize, low: T, step: T) -> Result<Self, AxisError>
pub fn with_step_size(num: usize, low: T, step: T) -> Result<Self, AxisError>
Factory method to create an axis with num uniformly spaced bins in the range [low, low+num*step). Under/overflow bins cover values outside this range.
The number of bins and step size must both be greater than zero, otherwise an error is returned. The number of bins must be representable in the type T, otherwise an error is returned.
Trait Implementations§
Source§impl<T: PartialOrd + NumCast + NumOps + Copy> Axis for Uniform<T>
impl<T: PartialOrd + NumCast + NumOps + Copy> Axis for Uniform<T>
Source§type Coordinate = T
type Coordinate = T
Source§type BinInterval = BinInterval<T>
type BinInterval = BinInterval<T>
Source§fn index(&self, coordinate: &Self::Coordinate) -> Option<usize>
fn index(&self, coordinate: &Self::Coordinate) -> Option<usize>
Source§fn num_bins(&self) -> usize
fn num_bins(&self) -> usize
Source§fn bin(&self, index: usize) -> Option<<Self as Axis>::BinInterval>
fn bin(&self, index: usize) -> Option<<Self as Axis>::BinInterval>
Source§fn iter(&self) -> Box<dyn Iterator<Item = (usize, Self::BinInterval)> + '_>
fn iter(&self) -> Box<dyn Iterator<Item = (usize, Self::BinInterval)> + '_>
Source§impl<'de, T> Deserialize<'de> for Uniform<T>where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for Uniform<T>where
T: Deserialize<'de>,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl<'a, T> IntoIterator for &'a Uniform<T>
impl<'a, T> IntoIterator for &'a Uniform<T>
Source§impl<T: Ord> Ord for Uniform<T>
impl<T: Ord> Ord for Uniform<T>
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl<T: PartialOrd> PartialOrd for Uniform<T>
impl<T: PartialOrd> PartialOrd for Uniform<T>
impl<T: Eq> Eq for Uniform<T>
impl<T> StructuralPartialEq for Uniform<T>
Auto Trait Implementations§
impl<T> Freeze for Uniform<T>where
T: Freeze,
impl<T> RefUnwindSafe for Uniform<T>where
T: RefUnwindSafe,
impl<T> Send for Uniform<T>where
T: Send,
impl<T> Sync for Uniform<T>where
T: Sync,
impl<T> Unpin for Uniform<T>where
T: Unpin,
impl<T> UnwindSafe for Uniform<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more