Function smartnoise_runtime::components::clamp::clamp_numeric_integer[][src]

pub fn clamp_numeric_integer(
    data: ArrayD<Integer>,
    lower: ArrayD<Integer>,
    upper: ArrayD<Integer>
) -> Result<ArrayD<Integer>>

Clamps each column of integral data to within desired range.

Arguments

Return

Data clamped to desired bounds.

Example

use ndarray::{ArrayD, arr2, arr1};
use smartnoise_runtime::components::clamp::clamp_numeric_integer;
use smartnoise_validator::Integer;
let data = arr2(&[ [1, 2, 3], [7, 11, 9] ]).into_dyn();
let lower: ArrayD<Integer> = arr1(&[0, 8, 4]).into_dyn();
let upper: ArrayD<Integer> = arr1(&[2, 10, 12]).into_dyn();

let clamped_data = clamp_numeric_integer(data, lower, upper).unwrap();
assert_eq!(clamped_data, arr2(&[ [1, 8, 4], [2, 10, 9] ]).into_dyn());