INNER CODE UNIT · Rust
shape_err
RyanCodrai/turbovec · turbovec-python/src/lib.rs:199
fn shape_err(e: numpy::ndarray::ShapeError) -> PyErr {
pyo3::exceptions::PyRuntimeError::new_err(format!(
"internal error: malformed search result shape: {e}"
))
}
/// Reject NaN / Inf / overflow-magnitude query coordinates with a typed
/// `ValueError`. The core `search` panics on invalid values (its documented
/// Rust contract), which would otherwise surface to Python as an uncatchable
/// `PanicException`. `add` already maps the same condition to `ValueError`;
/// this keeps `search` consistent.
///
/// The scan splits across the current rayon pool once the input exceeds one
/// chunk, so callers route it through [`with_pool`] then — see
/// [`validate_queries_pooled`].
fn validate_queries(values: &[f32], dim: usize) -> PyResult<()> {
if let Some((vi, ci, v)) = turbovec_core::first_invalid_coord(values, dim) {
return Err(pyo3::exceptions::PyValueError::new_err(format!(