- A
__version__
attribute relying onimportlib.metadata
.
- Drop official support for Python 3.8.
- Switch from
black
toruff
for code style. - Fully migrate to a
pyproject.toml
-based project. - Ensure code style consistency (see selected rules in
pyproject.toml
).
- The
how
function ofcombine
can access the current interval ifpass_interval
is set (see #97).
- The
combine
method of anIntervalDict
accepts amissing
parameter to fill values for non-overlapping keys (see #96). - A recipe to
combine
more than twoIntervalDict
(see #95).
- Drop official support for Python 3.7.
- Import error when using
create_api
in Python 3.10+ (see #87).
- Import error when using
create_api
outside a REPL (see #85).
- An
AbstractDiscreteInterval
class to ease the creation of specialized discrete intervals (experimental). - A
create_api
function to generate an API similar to the one ofportion
but configured to use a given subclass ofInterval
(experimental, see Specialize & customize intervals).
- Speed up
repr
andto_string
forInterval
instances (see #76, adm271828). - Some internal changes to ease subclassing:
from_string
andfrom_data
accepts aklass
parameter to specify which class should be used to createInterval
instances (default isInterval
).- Add a
klass
parameter foropen
,closed
,openclosed
,closedopen
,singleton
andempty
(default isInterval
). - Add a
_klass
class attribute inIntervalDict
to specify how to createInterval
instances (default isInterval
). IntervalDict
usesself.__class__
to preserve subclasses when creating new instances.
- Speed up lookups in
IntervalDict
for non-interval keys. - Speed up
iterate
by no longer creating singleton instances under the hood. - Drop official support for Python 3.6.
- Infinite recursion when a subclass of an
Interval
is compared using>
with anInterval
instance (see #75).
- Support for Python 3.10.
IntervalDict.as_dict
has an optionalatomic=False
parameter that, if set toTrue
, returns intervals that are atomic.- Experimental support for structural pattern matching (on
left
,lower
,upper
andright
).
- (breaking) Set
list(P.empty()) == []
, i.e., the empty interval is a disjunction of no interval (see #72). - (breaking) For consistency, the empty interval is never
<
,>
,<=
, nor>=
when compared to another interval. - Comparing an interval and a value is deprecated since it is ill-defined when the value is on the left of
<=
or>=
. Convert values to singletons first.
- Support PEP 517.
- Some internal changes to ease subclassing
Interval
(see #58):- Use
self.__class__
instead ofInterval
to create new instances; - Deprecate and move
mergeable
function toInterval._mergeable
class method; Interval.from_atomic
is now a class method instead of a static method.
- Use
- Speed up lookups in
IntervalDict
(#65, Jeff Trull). - Speed up removals in
IntervalDict
. - Speed up intersection for non-overlapping intervals (#66, Jeff Trull).
- Speed up
.overlaps
and.contains
for non-overlapping intervals/items.
- Drop official support for Python 3.5.
- Use
black
as official code formatting.
from_string
raises aValueError
if given string cannot be parsed to an interval (#57).
- Getting items from an
Interval
using a slice does no longer return alist
but anInterval
instance. - Intervals are properly pretty-printed by
pandas
(#54).
- Much faster
get
,copy
and|
operations forIntervalDict
.
- Empty intervals are contained in all intervals (#41).
IntervalDict
supports|
and|=
, the same waydict
will do starting from Python 3.9 (#37).
- Fix invalid simplification of 3+ intervals when a closed interval shares the lower bound of an open one (#38).
- Fix the order in which items are returned from an
IntervalDict
when a closed interval shares the lower bound of an open one (#39).
- Fix a regression introduced in 2.1.0 for
IntervalDict
(#36).
IntervalDict.as_dict()
to export its content to a classical Pythondict
.
IntervalDict.keys()
,values()
anditems()
return view objects instead of lists.
IntervalDict.popitem()
now returns a (key, value) pair instead of anIntervalDict
.- The documentation of
IntervalDict.pop()
now correctly states that the value (and not the key) is returned.
- Fix occasional
StopIteration
exception when checking for containment (#28).
- Fix invalid representations of non-atomic intervals composed of a singleton (#22).
i.empty
to check for interval emptiness.i.atomic
to check for interval atomicity.- An
adjacent
method to test whether two intervals are adjacent. i.__getitem__
supports slices.- Infinities define a hash value.
- Static method
Interval.from_atomic(left, lower, upper, right)
to create an interval composed of a single atomic interval (replacesAtomicInterval(left, lower, upper, right)
).
- (breaking)
python-intervals
has been renamedportion
. - (breaking) Many (optional) parameters are converted to keyword-only arguments:
- for
from_string
andto_string
:bound
,disj
,sep
,left_open
,left_closed
,right_open
,right_closed
,pinf
andninf
; - for
from_data
andto_data
:pinf
andninf
; - for
iterate
:base
andreverse
; - for
Interval.replace
:ignore_inf
.
- for
- (breaking)
incr
is replaced bystep
initerate
. - (breaking) For consistency with
range
, thestep
parameter initerate
is always added even ifreverse=True
. - (breaking)
i.enclosure
is a property and no longer a method. - (breaking) Indexing or iterating on the atomic intervals of an
Interval
returnsInterval
instances instead ofAtomicInterval
ones. - (breaking) An interval is hashable if and only if its bounds are hashable.
- Huge performance increase for creation, union, intersection, complement and difference of intervals (#21).
CLOSED
andOPEN
are members of theBound
enumeration.- Large refactoring to encapsulate
AtomicInterval
and all its operations inInterval
. - Restructure package in modules instead of a flat file.
- Reorganise tests in modules and classes instead of a flat file.
- Reorganise changelog with explicit categories.
- (breaking) Drop support for Python 2.7 and 3.4 since they reached end-of-life.
- (breaking)
AtomicInterval
is anamedtuple
and is no longer part of the public API. - (breaking) Remove
i.to_atomic()
(usei.enclosure
instead). - (breaking) Remove
i.is_empty()
(usei.empty
instead). - (breaking) Remove
i.is_atomic()
(usei.atomic
instead). - (breaking)
CLOSED
andOPEN
do no longer define an implicit Boolean value. Use~
instead ofnot
to invert a bound. - (breaking) Remove deprecated
permissive
ini.overlaps
. - (breaking) Remove
adjacent
ini.overlaps
, usei.adjacent
method instead.
- Fix an issue where an interval can be composed of duplicated empty intervals (#19).
- Fix performance issues when intervals composed of hundreds of atomic intervals are complemented (#20)
IntervalDict
has a.combine
method to merge its keys and values with anotherIntervalDict
.
- Discrete iteration on the values of an interval with
iterate
. - Map intervals to data with the dict-like
IntervalDict
structure.
- Faster comparisons between arbitrary values and intervals.
- Deprecate
permissive
in.overlaps
in favour ofadjacent
.
.union
when intervals share a bound, one inclusive and one exclusive (#12)..overlaps
when intervals share a lower bound, and one interval is contained within the other one (#13).
- Intervals have a
.left
,.lower
,.upper
, and.right
attribute that refer to its enclosure. - Intervals have a
.replace
method to create new intervals based on the current one. This method accepts both values and functions. - Intervals have an
.apply
method to apply a function on the underlying atomic intervals. - Intervals can be compared with single values as well.
P.empty()
returns the same instance to save memory.- Infinities are singleton objects.
- Set
len(P.empty()) = 1
andP.empty()[0] == P.empty().to_atomic()
for consistency.
- Import from and export to Python built-in data types (a list of 4-uples) with
from_data
andto_data
(#6). - Examples for arbitrary interval transformations.
- Support for customized infinity representation in
to_string
andfrom_string
(#3).
.overlaps
(#2).
- Invalid
repr
for atomic singleton intervals.
- Invalid comparisons when both
Interval
andAtomicInterval
are compared.
- #1 by making empty intervals always resolving to
(P.inf, -P.inf)
.
Interval.__init__
acceptsInterval
instances in addition toAtomicInterval
ones.
- Function
P.to_string
to export an interval to a string, with many options to customize the representation. - Function
P.from_string
to create an interval from a string, with many options to customize the parsing.
- Support for Python 2.7.
- More tests to cover all comparisons.
- Define
__slots__
to lower memory usage, and to speed up attribute access. - Define
Interval.__rand__
(and other magic methods) to supportInterval
fromAtomicInterval
instead of having a dedicated piece of code inAtomicInterval
. __all__
properly defined.
- Meaningful
<=
and>=
comparisons for intervals.
Interval
supports indexing to retrieve the underlyingAtomicInterval
objects.
- Both
AtomicInterval
andInterval
are fully comparable. singleton(x)
to create a singleton interval [x].empty()
to create an empty interval.Interval.enclosure()
that returns the smallest interval that includes the current one.
- Interval simplification is in O(n) instead of O(n*m).
AtomicInterval
objects in anInterval
are sorted by lower and upper bounds.
- All operations of
AtomicInterval
(except overlaps) acceptInterval
. - Raise
TypeError
instead ofValueError
if type is not supported (coherent withNotImplemented
).
- Initial release on PyPP.
- Initial release.