rsomics-gradient-trajectory 0.1.0

Gradient/trajectory ANOVA over ordination coordinates (QIIME-style microbiome trajectory analysis): per-group trajectory vectors plus closed-form one-way ANOVA F/p, selectable algorithm — a Rust reimplementation of scikit-bio's skbio.stats.gradient.
Documentation
use std::fmt::Write;

/// Append `x` as Python's `repr(float)` would: shortest round-trip decimal with
/// a trailing `.0` on integer-valued finite floats. Rust's `{}` already gives the
/// shortest round-trip form, so only the `.0` and non-finite cases differ.
pub fn push_pyrepr(buf: &mut String, x: f64) {
    if x.is_nan() {
        buf.push_str("nan");
        return;
    }
    if x.is_infinite() {
        buf.push_str(if x < 0.0 { "-inf" } else { "inf" });
        return;
    }
    let start = buf.len();
    let _ = write!(buf, "{x}");
    if !buf[start..].contains(['.', 'e', 'E']) {
        buf.push_str(".0");
    }
}

pub fn pyrepr(x: f64) -> String {
    let mut s = String::new();
    push_pyrepr(&mut s, x);
    s
}