The `intervals` library (version 0.9.2) provides basic tools for handling intervals or ranges of comparable objects in Python. It supports defining closed, open, or half-open intervals and performing operations such as checking for containment. This specific package, maintained by kvesteri, appears to be abandoned, with no updates since 2016, and its functionality has largely been superseded by other, more actively maintained interval libraries like `portion` (which itself evolved from a library called `python-intervals`).
pip install intervalsVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to create `Interval` objects using factory methods and directly, and how to perform a basic containment check. Note that rich interval operations (like `overlaps`, `intersection`, `union`) might be less intuitive or require manual implementation with this older, unmaintained library compared to modern alternatives.
Migrate to `portion` (pip install portion) or `intervaltree` (pip install intervaltree).
Ensure that if the lower and upper bounds are identical, at least one of the interval's boundaries is closed. For example, use `Interval.closed(a, a)` for a singleton or `Interval.closedopen(a, a)` for an empty interval with one closed bound.
Explicitly import and use specialized interval classes like `IntInterval`, `FloatInterval`, `DateInterval`, `DateTimeInterval` when working with known data types, rather than relying solely on the generic `Interval()` factory.
If you need to iterate over discrete values within an interval, you must explicitly generate them (e.g., using `range()` for integer intervals) or convert the interval to a list of its atomic components if it's an `IntervalSet` (though this library's `Interval` class is not a set of points). For `portion` (a recommended alternative), you can use `P.open(1, 5).iterate(int)`.
To represent an empty interval with equal bounds, ensure at least one bound is closed, e.g., `Interval.closedopen(5, 5)` or `Interval.openclosed(5, 5)` will correctly yield an empty interval. For a singleton, use `Interval.closed(5, 5)`.
To check for overlap with this library, you would typically need to implement the logic manually by comparing the bounds of the two intervals (e.g., `max(interval1.lower, interval2.lower) < min(interval1.upper, interval2.upper)` considering open/closed bounds). Alternatively, consider migrating to a more feature-rich library like `portion` which provides a dedicated `overlaps()` method.
No dependency data recorded yet.