Trait arr_rs::numeric::operations::binary_bits::ArrayBinaryBits
source · pub trait ArrayBinaryBitswhere
Self: Sized + Clone,{
// Required methods
fn unpack_bits(
&self,
axis: Option<isize>,
count: Option<isize>,
bit_order: Option<BitOrder>
) -> Result<Array<u8>, ArrayError>;
fn pack_bits(
&self,
axis: Option<isize>,
bit_order: Option<BitOrder>
) -> Result<Array<u8>, ArrayError>;
}Expand description
ArrayTrait - Binary Array bits operations
Required Methods§
sourcefn unpack_bits(
&self,
axis: Option<isize>,
count: Option<isize>,
bit_order: Option<BitOrder>
) -> Result<Array<u8>, ArrayError>
fn unpack_bits( &self, axis: Option<isize>, count: Option<isize>, bit_order: Option<BitOrder> ) -> Result<Array<u8>, ArrayError>
Unpacks elements of a uint8 array into a binary-valued output array
Arguments
axis- the dimension over which bit-unpacking is done. if none, array is flattenedcount- the number of elements to unpack along axis. if negative, array is trimmedbit_order- the order of the returned bits. defaults toBig
Examples
use arr_rs::prelude::*;
let expected: Result<Array<u8>, _> = array!([[0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 1, 0, 1, 1, 1]]);
let array: Result<Array<u8>, _> = array!([[2], [7], [23]]);
assert_eq!(expected, array.unpack_bits(Some(1), None, None));sourcefn pack_bits(
&self,
axis: Option<isize>,
bit_order: Option<BitOrder>
) -> Result<Array<u8>, ArrayError>
fn pack_bits( &self, axis: Option<isize>, bit_order: Option<BitOrder> ) -> Result<Array<u8>, ArrayError>
Packs the elements of a binary-valued array into bits in a uint8 array
Arguments
axis- the dimension over which bit-packing is done. if none, array is flattenedbit_order- the order of the returned bits. defaults toBig
Examples
use arr_rs::prelude::*;
let expected: Result<Array<u8>, _> = array!([[2], [7], [23]]);
let array: Result<Array<u8>, _> = array!([[0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 1, 0, 1, 1, 1]]);
assert_eq!(expected, array.pack_bits(Some(1), None));