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

pub fn clamp_numeric_float(
    data: ArrayD<Float>,
    lower: ArrayD<Float>,
    upper: ArrayD<Float>
) -> Result<ArrayD<Float>>

Clamps each column of float 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_float;
use smartnoise_validator::Float;
let data = arr2(&[ [1.,2.,3.], [7.,11.,9.] ]).into_dyn();
let lower: ArrayD<Float> = arr1(&[0.5, 8., 4.]).into_dyn();
let upper: ArrayD<Float> = arr1(&[2.5, 10., 12.]).into_dyn();

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