vortex_array/arrays/bool/compute/
mod.rs

1// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: Copyright the Vortex contributors
3
4mod cast;
5mod fill_null;
6pub mod filter;
7mod invert;
8mod is_constant;
9mod is_sorted;
10mod mask;
11mod min_max;
12mod sum;
13mod take;
14
15#[cfg(test)]
16mod tests {
17    use rstest::rstest;
18
19    use crate::arrays::BoolArray;
20    use crate::compute::conformance::consistency::test_array_consistency;
21
22    #[rstest]
23    // Basic bool arrays
24    #[case::bool_array(BoolArray::from_iter([true, false, true, true, false]))]
25    #[case::nullable_bool(BoolArray::from_iter([Some(true), None, Some(false), Some(true), None]))]
26    // Edge cases
27    #[case::single_true(BoolArray::from_iter([true]))]
28    #[case::single_false(BoolArray::from_iter([false]))]
29    #[case::two_elements(BoolArray::from_iter([true, false]))]
30    #[case::all_true(BoolArray::from_iter([true, true, true, true, true]))]
31    #[case::all_false(BoolArray::from_iter([false, false, false, false, false]))]
32    // Large arrays
33    #[case::large_alternating(BoolArray::from_iter((0..2000).map(|i| i % 2 == 0)))]
34    #[case::large_sparse_true(BoolArray::from_iter((0..2000).map(|i| i % 100 == 0)))]
35    #[case::large_nullable(BoolArray::from_iter((0..2000).map(|i| (i % 10 == 0).then_some(i % 3 == 0))))]
36    // Patterns
37    #[case::runs_pattern(BoolArray::from_iter(
38        [true, true, true, false, false, false, true, true, true, false, false, false]
39    ))]
40    #[case::mostly_null(BoolArray::from_iter([
41        None, None, Some(true), None, None, None, Some(false), None, None
42    ]))]
43    fn test_bool_consistency(#[case] array: BoolArray) {
44        test_array_consistency(array.as_ref());
45    }
46}