Struct ndhistogram::axis::Uniform
source · 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.
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>where
T: PartialOrd + Num + NumCast + NumOps + Copy,
impl<T> Uniform<T>where T: PartialOrd + Num + NumCast + NumOps + Copy,
sourcepub fn new(num: usize, low: T, high: T) -> Selfwhere
T: Float,
pub fn new(num: usize, low: T, high: T) -> Selfwhere 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.
Panics
Panics if num bins == 0 or low == high.
sourcepub fn with_step_size(num: usize, low: T, step: T) -> Self
pub fn with_step_size(num: usize, low: T, step: T) -> Self
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.
Panics
Panics if num bins == 0 or step <= 0.
Trait Implementations§
source§impl<T: PartialOrd + NumCast + NumOps + Copy> Axis for Uniform<T>
impl<T: PartialOrd + NumCast + NumOps + Copy> Axis for Uniform<T>
§type Coordinate = T
type Coordinate = T
The type representing a location on this axis.
§type BinInterval = BinInterval<T>
type BinInterval = BinInterval<T>
The type of an interval representing the set of Coordinates that correspond to a histogram bin
source§fn index(&self, coordinate: &Self::Coordinate) -> Option<usize>
fn index(&self, coordinate: &Self::Coordinate) -> Option<usize>
Map from coordinate to bin number.
Returns an option as not all valid coordinates are necessarily contained within a bin.
source§fn num_bins(&self) -> usize
fn num_bins(&self) -> usize
The number of bins in this axis, including underflow and overflow.
source§fn bin(&self, index: usize) -> Option<<Self as Axis>::BinInterval>
fn bin(&self, index: usize) -> Option<<Self as Axis>::BinInterval>
Map from bin number to axis to the interval covering the range of coordinates that this bin contains.
Returns an option in case an index >= Axis::num_bins is given.
source§fn iter(&self) -> Box<dyn Iterator<Item = (usize, Self::BinInterval)> + '_>
fn iter(&self) -> Box<dyn Iterator<Item = (usize, Self::BinInterval)> + '_>
An iterator over bin numbers and bin intervals
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>,
Deserialize this value from the given Serde deserializer. Read more
source§impl<'a, T> IntoIterator for &'a Uniform<T>where
Uniform<T>: Axis,
impl<'a, T> IntoIterator for &'a Uniform<T>where Uniform<T>: Axis,
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,
Compares and returns the maximum of two values. Read more
source§impl<T: PartialEq> PartialEq<Uniform<T>> for Uniform<T>
impl<T: PartialEq> PartialEq<Uniform<T>> for Uniform<T>
source§impl<T: PartialOrd> PartialOrd<Uniform<T>> for Uniform<T>
impl<T: PartialOrd> PartialOrd<Uniform<T>> for Uniform<T>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moreimpl<T: Eq> Eq for Uniform<T>
impl<T> StructuralEq for Uniform<T>
impl<T> StructuralPartialEq for Uniform<T>
Auto Trait Implementations§
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
Mutably borrows from an owned value. Read more