Struct ndarray_stats::histogram::Edges [−][src]
A sorted collection of type A
elements used to represent the boundaries of intervals, i.e.
Bins
on a 1-dimensional axis.
Note that all intervals are left-closed and right-open. See examples below.
Examples
use ndarray_stats::histogram::{Bins, Edges}; use noisy_float::types::n64; let unit_edges = Edges::from(vec![n64(0.), n64(1.)]); let unit_interval = Bins::new(unit_edges); // left-closed assert_eq!( unit_interval.range_of(&n64(0.)).unwrap(), n64(0.)..n64(1.), ); // right-open assert_eq!( unit_interval.range_of(&n64(1.)), None );
Implementations
impl<A: Ord> Edges<A>
[src]
#[must_use]pub fn len(&self) -> usize
[src]
Returns the number of edges in self
.
Examples
use ndarray_stats::histogram::Edges; use noisy_float::types::n64; let edges = Edges::from(vec![n64(0.), n64(1.), n64(3.)]); assert_eq!( edges.len(), 3 );
#[must_use]pub fn is_empty(&self) -> bool
[src]
Returns true
if self
contains no edges.
Examples
use ndarray_stats::histogram::Edges; use noisy_float::types::{N64, n64}; let edges = Edges::<N64>::from(vec![]); assert_eq!(edges.is_empty(), true); let edges = Edges::from(vec![n64(0.), n64(2.), n64(5.)]); assert_eq!(edges.is_empty(), false);
#[must_use]pub fn as_array_view(&self) -> ArrayView1<'_, A>
[src]
Returns an immutable 1-dimensional array view of edges.
Examples
use ndarray::array; use ndarray_stats::histogram::Edges; let edges = Edges::from(vec![0, 5, 3]); assert_eq!( edges.as_array_view(), array![0, 3, 5].view() );
pub fn indices_of(&self, value: &A) -> Option<(usize, usize)>
[src]
Returns indices of two consecutive edges
in self
, if the interval they represent
contains the given value
, or returns None
otherwise.
That is to say, it returns
Some((left, right))
, whereleft
andright
are the indices of two consecutive edges inself
andright == left + 1
, ifself[left] <= value < self[right]
;None
, otherwise.
Examples
use ndarray_stats::histogram::Edges; let edges = Edges::from(vec![0, 2, 3]); // `1` is in the interval [0, 2), whose indices are (0, 1) assert_eq!( edges.indices_of(&1), Some((0, 1)) ); // `5` is not in any of intervals assert_eq!( edges.indices_of(&5), None );
pub fn iter(&self) -> impl Iterator<Item = &A>
[src]
Returns an iterator over the edges
in self
.
Trait Implementations
impl<A: Clone + Ord> Clone for Edges<A>
[src]
impl<A: Debug + Ord> Debug for Edges<A>
[src]
impl<A: Eq + Ord> Eq for Edges<A>
[src]
impl<A: Ord + Clone> From<ArrayBase<OwnedRepr<A>, Dim<[usize; 1]>>> for Edges<A>
[src]
fn from(edges: Array1<A>) -> Self
[src]
Converts an Array1<A>
into an Edges<A>
, consuming the 1-dimensional array.
The array will be sorted in increasing order using an unstable sorting algorithm, with
duplicates removed.
Current implementation
The current sorting algorithm is the same as std::slice::sort_unstable()
,
which is based on pattern-defeating quicksort.
This sort is unstable (i.e., may reorder equal elements), in-place (i.e., does not allocate) , and O(n log n) worst-case.
Examples
use ndarray_stats::histogram::Edges; let edges = Edges::from(vec![1, 15, 10, 20]); // The vec gets sorted! assert_eq!( edges[1], 10 );
impl<A: Ord> From<Vec<A, Global>> for Edges<A>
[src]
fn from(edges: Vec<A>) -> Self
[src]
Converts a Vec<A>
into an Edges<A>
, consuming the edges.
The vector will be sorted in increasing order using an unstable sorting algorithm, with
duplicates removed.
Current implementation
The current sorting algorithm is the same as std::slice::sort_unstable()
,
which is based on pattern-defeating quicksort.
This sort is unstable (i.e., may reorder equal elements), in-place (i.e., does not allocate) , and O(n log n) worst-case.
Examples
use ndarray::array; use ndarray_stats::histogram::Edges; let edges = Edges::from(array![1, 15, 10, 10, 20]); // The array gets sorted! assert_eq!( edges[2], 15 );
impl<A: Ord> Index<usize> for Edges<A>
[src]
impl<A: PartialEq + Ord> PartialEq<Edges<A>> for Edges<A>
[src]
impl<A: Ord> StructuralEq for Edges<A>
[src]
impl<A: Ord> StructuralPartialEq for Edges<A>
[src]
Auto Trait Implementations
impl<A> RefUnwindSafe for Edges<A> where
A: RefUnwindSafe,
A: RefUnwindSafe,
impl<A> Send for Edges<A> where
A: Send,
A: Send,
impl<A> Sync for Edges<A> where
A: Sync,
A: Sync,
impl<A> Unpin for Edges<A> where
A: Unpin,
A: Unpin,
impl<A> UnwindSafe for Edges<A> where
A: UnwindSafe,
A: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<Q, K> Equivalent<K> for Q where
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
[src]
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
pub fn equivalent(&self, key: &K) -> bool
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,