Struct ndarray_stats::histogram::GridBuilder [−][src]
A builder used to create Grid
instances for histogram
computations.
Examples
Basic usage, creating a Grid
with some observations and a given strategy
:
use ndarray::Array; use ndarray_stats::histogram::{strategies::Auto, Bins, Edges, Grid, GridBuilder}; // 1-dimensional observations, as a (n_observations, n_dimension) 2-d matrix let observations = Array::from_shape_vec( (12, 1), vec![1, 4, 5, 2, 100, 20, 50, 65, 27, 40, 45, 23], ).unwrap(); // The optimal grid layout is inferred from the data, given a chosen strategy, Auto in this case let grid = GridBuilder::<Auto<usize>>::from_array(&observations).unwrap().build(); // Equivalently, build a Grid directly let expected_grid = Grid::from(vec![Bins::new(Edges::from(vec![1, 20, 39, 58, 77, 96, 115]))]); assert_eq!(grid, expected_grid);
Implementations
impl<A, B> GridBuilder<B> where
A: Ord,
B: BinsBuildingStrategy<Elem = A>,
[src]
A: Ord,
B: BinsBuildingStrategy<Elem = A>,
pub fn from_array<S>(array: &ArrayBase<S, Ix2>) -> Result<Self, BinsBuildError> where
S: Data<Elem = A>,
[src]
S: Data<Elem = A>,
Returns a GridBuilder
for building a Grid
with a given strategy
and some
observations in a 2-dimensionalarray with shape (n_observations, n_dimension)
.
Errors
It returns BinsBuildError
if it is not possible to build a Grid
given
the observed data according to the chosen strategy
.
Examples
See Trait-level examples for basic usage.
#[must_use]pub fn build(&self) -> Grid<A>
[src]
Returns a Grid
instance, with building parameters infered in from_array
, according
to the specified strategy
and observations provided.
Examples
See [Trait-level examples] for basic usage.
Auto Trait Implementations
impl<B> RefUnwindSafe for GridBuilder<B> where
B: RefUnwindSafe,
B: RefUnwindSafe,
impl<B> Send for GridBuilder<B> where
B: Send,
B: Send,
impl<B> Sync for GridBuilder<B> where
B: Sync,
B: Sync,
impl<B> Unpin for GridBuilder<B> where
B: Unpin,
B: Unpin,
impl<B> UnwindSafe for GridBuilder<B> where
B: UnwindSafe,
B: 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<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
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>,