pub trait ArrayStatCompat<T> {
// Required methods
fn mean_or(&self, default: T) -> T;
fn var_or(&self, ddof: T, default: T) -> T;
fn std_or(&self, ddof: T, default: T) -> T;
}Expand description
Compatibility extensions for ndarray statistical operations
This trait provides stable statistical operation APIs that remain consistent across ndarray version updates, implementing the SciRS2 POLICY principle of isolating external dependency changes to scirs2-core only.
§Rationale
ndarray’s statistical methods have changed across versions:
- v0.16:
.mean()returnsOption<T> - v0.17:
.mean()returnsTdirectly (may be NaN for invalid operations)
This trait provides a consistent API regardless of the underlying ndarray version.
§Example
use scirs2_core::ndarray::{Array1, compat::ArrayStatCompat};
let data = Array1::from(vec![1.0, 2.0, 3.0]);
let mean = data.mean_or(0.0); // Stable API across ndarray versions