Struct ndarray_stats::histogram::GridBuilder[][src]

pub struct GridBuilder<B: BinsBuildingStrategy> { /* fields omitted */ }

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]

pub fn from_array<S>(array: &ArrayBase<S, Ix2>) -> Result<Self, BinsBuildError> where
    S: Data<Elem = A>, 
[src]

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

impl<B> Send for GridBuilder<B> where
    B: Send

impl<B> Sync for GridBuilder<B> where
    B: Sync

impl<B> Unpin for GridBuilder<B> where
    B: Unpin

impl<B> UnwindSafe for GridBuilder<B> where
    B: UnwindSafe

Blanket Implementations

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

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

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

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

impl<T, U> Into<U> for T where
    U: From<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<V, T> VZip<V> for T where
    V: MultiLane<T>,