Skip to main content

interval_range_by_step

Function interval_range_by_step 

Source
pub fn interval_range_by_step(
    start: f64,
    end: f64,
    step: f64,
    closed: IntervalClosed,
) -> Result<Vec<Interval>, TypeError>
Expand description

Build equal-step-width intervals spanning [start, end].

Matches pd.interval_range(start, end, freq=step, closed=...) for the numeric-subtype case. step must be finite and positive; (end - start) must be an integer multiple of step (within float tolerance) — pandas raises ValueError otherwise; this fn returns Err(TypeError::IntervalStepDoesNotDivide).

Returns an empty vector when start == end (matches pandas’ zero-bin IntervalIndex); returns an empty vector when start > end (pandas also returns empty rather than erroring in this case).