pub struct Interval {
pub left: f64,
pub right: f64,
pub closed: IntervalClosed,
pub subtype: IntervalSubtype,
}Expand description
A bounded numeric interval between two f64 endpoints.
Matches pd.Interval(left, right, closed) on the numeric-subtype path.
Accessors match pandas: .left, .right, .closed, .length, .mid,
.contains, .is_empty, .overlaps. Equality ignores the subtype, as
pandas’ Interval(0, 3) == Interval(0.0, 3.0).
Fields§
§left: f64§right: f64§closed: IntervalClosed§subtype: IntervalSubtypeThe endpoints’ type as pandas reports and prints it.
Implementations§
Source§impl Interval
impl Interval
Sourcepub const fn new(left: f64, right: f64, closed: IntervalClosed) -> Self
pub const fn new(left: f64, right: f64, closed: IntervalClosed) -> Self
Construct an interval. No validation on left <= right — pandas also
accepts reversed intervals (they’re non-empty only if empty-by-design).
Sourcepub fn with_int_endpoints(self) -> Self
pub fn with_int_endpoints(self) -> Self
This interval with integer endpoints (pandas’ interval[int64])
when both are whole numbers; unchanged otherwise.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Empty iff endpoints coincide AND at least one side is open.
Pandas semantics: pd.Interval(3, 3, 'right').is_empty → True.
Sourcepub fn contains(&self, value: f64) -> bool
pub fn contains(&self, value: f64) -> bool
Does value fall inside this interval?
NaN always returns false, matching pandas pd.Interval.__contains__
behavior (NaN doesn’t compare equal to anything).
Sourcepub fn overlaps(&self, other: &Self) -> bool
pub fn overlaps(&self, other: &Self) -> bool
Do self and other share any point?
Matches pd.Interval.overlaps(other). Two intervals overlap iff the
max of their lefts is less than the min of their rights, with
endpoint-inclusion determining the strictness of the comparison when
they touch exactly.
Trait Implementations§
impl Copy for Interval
Source§impl<'de> Deserialize<'de> for Interval
impl<'de> Deserialize<'de> for Interval
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Display for Interval
impl Display for Interval
Source§fn fmt(&self, f: &mut Formatter<'_>) -> Result
fn fmt(&self, f: &mut Formatter<'_>) -> Result
Matches str(pd.Interval(...)): interval[float64] endpoints render
with Python str(float) semantics, so whole numbers KEEP “.0”
(str(pd.Interval(0.0, 5.0, 'right')) is "(0.0, 5.0]", not "(0, 5]").
Verified vs pandas 2.2.3 across whole/fractional/negative/scientific
endpoints. (br-frankenpandas-5xw1b) The interval[int64] subtype
prints integers ("(0, 5]").
impl Eq for Interval
An interval as a label (an IntervalIndex’s; br-frankenpandas-c27hq): its endpoints compare as floats, so only an interval with a NaN endpoint, which pandas never builds, is unequal to itself.
Source§impl Hash for Interval
Hashed as it compares: the endpoints (-0.0 as 0.0) and the closed side;
the subtype is not part of the value.
impl Hash for Interval
Hashed as it compares: the endpoints (-0.0 as 0.0) and the closed side; the subtype is not part of the value.
Source§impl Ord for Interval
pandas’ IntervalIndex order: by the left endpoint, then the right, then
the closed side.
impl Ord for Interval
pandas’ IntervalIndex order: by the left endpoint, then the right, then the closed side.