[][src]Struct ndarray_stats::histogram::Edges

pub struct Edges<A: Ord> { /* fields omitted */ }

Edges is a sorted collection of A elements used to represent the boundaries of intervals (Bins) on a 1-dimensional axis.

Example:

use ndarray_stats::histogram::{Edges, Bins};
use noisy_float::types::n64;

let unit_edges = Edges::from(vec![n64(0.), n64(1.)]);
let unit_interval = Bins::new(unit_edges);
// left inclusive
assert_eq!(
    unit_interval.range_of(&n64(0.)).unwrap(),
    n64(0.)..n64(1.),
);
// right exclusive
assert_eq!(
    unit_interval.range_of(&n64(1.)),
    None
);

Methods

impl<A: Ord> Edges<A>[src]

pub fn len(&self) -> usize[src]

Number of edges in self.

Example:

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
);

pub fn as_array_view(&self) -> ArrayView1<A>[src]

Borrow an immutable reference to the edges as a 1-dimensional array view.

Example:

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]

Given value, it returns an option:

  • Some((left, right)), where right=left+1, if there are two consecutive edges in self such that self[left] <= value < self[right];
  • None, otherwise.

Example:

use ndarray_stats::histogram::Edges;

let edges = Edges::from(vec![0, 2, 3]);
assert_eq!(
    edges.indices_of(&1),
    Some((0, 1))
);
assert_eq!(
    edges.indices_of(&5),
    None
);

pub fn iter(&self) -> impl Iterator<Item = &A>[src]

Trait Implementations

impl<A: Eq + Ord> Eq for Edges<A>[src]

impl<A: Clone + Ord> Clone for Edges<A>[src]

impl<A: PartialEq + Ord> PartialEq<Edges<A>> for Edges<A>[src]

impl<A: Ord> From<Vec<A>> for Edges<A>[src]

fn from(edges: Vec<A>) -> Self[src]

Get an Edges instance from a Vec<A>: the vector will be sorted in increasing order using an unstable sorting algorithm and duplicates will be removed.

Example:

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 + Clone> From<ArrayBase<OwnedRepr<A>, Dim<[usize; 1]>>> for Edges<A>[src]

fn from(edges: Array1<A>) -> Self[src]

Get an Edges instance from a Array1<A>: the array elements will be sorted in increasing order using an unstable sorting algorithm and duplicates will be removed.

Example:

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> Index<usize> for Edges<A>[src]

type Output = A

The returned type after indexing.

fn index(&self, i: usize) -> &Self::Output[src]

Get the i-th edge.

Panics if the index i is out of bounds.

Example:

use ndarray_stats::histogram::Edges;

let edges = Edges::from(vec![1, 5, 10, 20]);
assert_eq!(
    edges[1],
    5
);

impl<A: Debug + Ord> Debug for Edges<A>[src]

Auto Trait Implementations

impl<A> Send for Edges<A> where
    A: Send

impl<A> Unpin for Edges<A> where
    A: Unpin

impl<A> Sync for Edges<A> where
    A: Sync

impl<A> UnwindSafe for Edges<A> where
    A: UnwindSafe

impl<A> RefUnwindSafe for Edges<A> where
    A: RefUnwindSafe

Blanket Implementations

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,