Skip to main content

pad_to

Function pad_to 

Source
pub fn pad_to(v: &[f64], len: usize) -> Vec<f64>
Expand description

Right-pad a vector with its last value, or 0.0 when empty.

pad_to is a grow-only helper used to lift a short column up to the common wire width of a ragged reference frame; the padded tail is never read by a correctly-sliced reference body. Asking it to shrink a column (target shorter than the source) is always a caller bug — it would silently drop the tail of real data — so this is a hard error with an actionable message rather than a quiet truncation. The usual culprit is padding a full-data column to a train-split width: pad every column to a single n = max(len) and slice each by its own semantic length inside the reference body instead.