Summary
mohu-index handles indexing strategies beyond basic slicing. Implement boolean mask indexing and integer array (fancy) indexing -- the two most common advanced indexing patterns.
API surface
// crates/mohu-index/src/lib.rs
pub fn index_bool(src: &Buffer, mask: &Buffer) -> MohuResult<Buffer>;
pub fn index_take(src: &Buffer, indices: &Buffer, axis: usize) -> MohuResult<Buffer>;
Behavior
index_bool (boolean mask):
mask dtype must be DType::Bool; otherwise DomainError
mask must have same shape as src; otherwise ShapeMismatch
- Returns 1D buffer of elements where mask is
true
index_take (integer array indexing):
indices dtype must be DType::I64; otherwise DomainError
- Selects elements along
axis at positions given by indices
- Out-of-bounds index returns
MohuError::IndexOutOfBounds
- Negative indices not supported in v1 (return
IndexOutOfBounds)
Acceptance criteria
Signed-off-by: Bbn08 atrancendentbeing@gmail.com
Summary
mohu-indexhandles indexing strategies beyond basic slicing. Implement boolean mask indexing and integer array (fancy) indexing -- the two most common advanced indexing patterns.API surface
Behavior
index_bool (boolean mask):
maskdtype must beDType::Bool; otherwiseDomainErrormaskmust have same shape assrc; otherwiseShapeMismatchtrueindex_take (integer array indexing):
indicesdtype must beDType::I64; otherwiseDomainErroraxisat positions given byindicesMohuError::IndexOutOfBoundsIndexOutOfBounds)Acceptance criteria
index_boolextracts correct elements for 1D and 2D maskindex_takegathers correct rows/cols for 1D and 2D src.unwrap()in library codeSigned-off-by: Bbn08 atrancendentbeing@gmail.com