pub struct Edges<A: Ord> { /* private fields */ }
Expand description

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

Example:

extern crate ndarray_stats;
extern crate noisy_float;
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
);

Implementations

Number of edges in self.

Example:
extern crate ndarray_stats;
extern crate noisy_float;
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
);

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

Example:
extern crate ndarray;
extern crate ndarray_stats;
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()
);

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:
extern crate ndarray_stats;
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
);

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more

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:
extern crate ndarray_stats;
use ndarray_stats::histogram::Edges;

let edges = Edges::from(vec![1, 15, 10, 20]);
// The vec gets sorted!
assert_eq!(
    edges[1],
    10
);

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:
extern crate ndarray_stats;
#[macro_use(array)]
extern crate ndarray;
use ndarray_stats::histogram::Edges;

let edges = Edges::from(array![1, 15, 10, 10, 20]);
// The array gets sorted!
assert_eq!(
    edges[2],
    15
);

Get the i-th edge.

Panics if the index i is out of bounds.

Example:
extern crate ndarray_stats;
use ndarray_stats::histogram::Edges;

let edges = Edges::from(vec![1, 5, 10, 20]);
assert_eq!(
    edges[1],
    5
);
The returned type after indexing.
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.