matten-mlprep 0.19.1

Small, transparent, deterministic preprocessing helpers for matten::Tensor (no ML framework).
Documentation
//! Shared input guard for `matten-mlprep` (RFC-028 §3, §6).

use crate::error::MattenMlprepError;
use matten::Tensor;

/// Validates that `x` is a numeric rank-2 tensor and returns `(rows, cols)`.
///
/// Enforces the `rows = samples`, `columns = features` convention for every
/// public entry point. Rejects dynamic tensors unconditionally — this guard
/// does not depend on the companion `dynamic` feature being enabled (RFC-031).
pub(crate) fn matrix_dims(x: &Tensor) -> Result<(usize, usize), MattenMlprepError> {
    if x.is_dynamic() {
        return Err(MattenMlprepError::DynamicTensor);
    }

    let shape = x.shape();
    if shape.len() != 2 {
        return Err(MattenMlprepError::ExpectedMatrix {
            shape: shape.to_vec(),
        });
    }
    Ok((shape[0], shape[1]))
}