portion, a Python library providing data structure and operations for intervals.
Fixes import error in create_api
for Python 3.10+ (see #87)
Fix import error when using create_api
outside a REPL (see #85).
AbstractDiscreteInterval
class to ease the creation of specialized discrete intervals (experimental).create_api
function to generate an API similar to the one of portion
but configured to use a given subclass of Interval
(experimental, see Specialize & customize intervals).repr
and to_string
for Interval
instances (see #76, adm271828).from_string
and from_data
accepts a klass
parameter to specify which class should be used to create Interval
instances (default is Interval
).klass
parameter for open
, closed
, openclosed
, closedopen
, singleton
and empty
(default is Interval
)._klass
class attribute in IntervalDict
to specify how to create Interval
instances (default is Interval
).IntervalDict
uses self.__class__
to preserve subclasses when creating new instances.IntervalDict
for non-interval keys.iterate
by no longer creating singleton instances under the hood.Interval
is compared using >
with an Interval
instance (see #75).IntervalDict.as_dict
has an optional atomic=False
parameter that, if set to True
, returns intervals that are atomic.left
, lower
, upper
and right
).list(P.empty()) == []
, i.e., the empty interval is a disjunction of no interval (see #72).<
, >
, <=
, nor >=
when compared to another interval.<=
or >=
. Convert values to singletons first.Interval
(see #58):
self.__class__
instead of Interval
to create new instances;mergeable
function to Interval._mergeable
class method;Interval.from_atomic
is now a class method instead of a static method.IntervalDict
(#65, Jeff Trull).IntervalDict
..overlaps
and .contains
for non-overlapping intervals/items.from_string
raises a ValueError
if given string cannot be parsed to an interval (#57).black
as official code formatting.Fixes:
Interval
using a slice does no longer return a list
but an Interval
instance.pandas
(#54).Much faster get
, copy
and |
operations for IntervalDict
.
Soften dependency constraint towards sortedcontainers (#47).