rsomics-anosim 0.1.0

ANOSIM (Clarke 1993) test for group differences from a distance matrix — scikit-bio skbio.stats.distance.anosim equivalent (tie-averaged ranks, permutation p-value)
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");
    }
}