pub struct Interval {
pub left: f64,
pub right: f64,
pub closed: IntervalClosed,
}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.
Fields§
§left: f64§right: f64§closed: IntervalClosedImplementations§
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 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(...)) for the interval[float64] subtype, which
is the only subtype FrankenPandas stores (f64 endpoints): the 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)