pub mod advanced;
pub mod basic;
pub mod extended;
pub use extended::{
MaskKind, argwhere, extract, flatnonzero, mask_indices, nonzero, place, putmask,
ravel_multi_index, unravel_index,
};
use crate::error::{FerrayError, FerrayResult};
#[inline]
pub(crate) const fn normalize_index(index: isize, size: usize, axis: usize) -> FerrayResult<usize> {
if index < 0 {
let pos = size as isize + index;
if pos < 0 {
return Err(FerrayError::index_out_of_bounds(index, axis, size));
}
Ok(pos as usize)
} else {
let idx = index as usize;
if idx >= size {
return Err(FerrayError::index_out_of_bounds(index, axis, size));
}
Ok(idx)
}
}