unique

Function unique 

Source
pub fn unique<T>(
    array: ArrayView<'_, T, Ix1>,
) -> Result<Array<T, Ix1>, &'static str>
where T: Clone + Ord,
Expand description

Find unique elements in an array

§Arguments

  • array - The input 1D array

§Returns

A 1D array containing the unique elements of the input array, sorted

§Examples

use ndarray::array;
use scirs2_core::ndarray_ext::manipulation::unique;

let a = array![3, 1, 2, 2, 3, 4, 1];
let result = unique(a.view()).unwrap();
assert_eq!(result, array![1, 2, 3, 4]);