Problem
DenseMatrix::from_iterator(iter, nrows, ncols, axis: u8) (and related axis-taking APIs) use u8 magic numbers: 0 = row-major fill, 1 = column-major fill.
Two failure modes observed downstream (genefold test suite):
- Accidental transposition — passing
1 where 0 was meant silently transposes the matrix; dimensions still match, values are wrong. This actually happened across fixtures in the same codebase.
- Undocumented convention — the meaning of 0/1 is only discoverable from source; nothing in the type prevents
2.
Proposal
pub enum Axis { Row = 0, Col = 1 }
impl DenseMatrix<T> {
pub fn from_iterator_axis(iter: I, nrows: usize, ncols: usize, axis: Axis) -> Result<Self, Failed>;
}
- New enum-taking methods first (no breakage of existing
u8 signatures, deprecate later);
TryFrom<u8> for Axis so stringly/CLI boundaries convert with an error instead of a wrong-number bug.
A repo-wide grep shows the axis: u8 convention repeats across other constructors/iterators — worth treating uniformly.
Problem
DenseMatrix::from_iterator(iter, nrows, ncols, axis: u8)(and related axis-taking APIs) useu8magic numbers:0= row-major fill,1= column-major fill.Two failure modes observed downstream (genefold test suite):
1where0was meant silently transposes the matrix; dimensions still match, values are wrong. This actually happened across fixtures in the same codebase.2.Proposal
u8signatures, deprecate later);TryFrom<u8>forAxisso stringly/CLI boundaries convert with an error instead of a wrong-number bug.A repo-wide grep shows the
axis: u8convention repeats across other constructors/iterators — worth treating uniformly.