Function polars::export::arrow::compute::arithmetics::basic::checked_negate
source · [−]pub fn checked_negate<T>(array: &PrimitiveArray<T>) -> PrimitiveArray<T> where
T: NativeType + CheckedNeg,
This is supported on crate feature
compute_arithmetics
only.Expand description
Checked negates values from array.
Examples
use arrow2::compute::arithmetics::basic::checked_negate;
use arrow2::array::{Array, PrimitiveArray};
let a = PrimitiveArray::from([None, Some(6), Some(i8::MIN), Some(7)]);
let result = checked_negate(&a);
let expected = PrimitiveArray::from([None, Some(-6), None, Some(-7)]);
assert_eq!(result, expected);
assert!(!result.is_valid(2))