constraints.intervals

Module: constraints.intervals

Inheritance diagram for selectinf.constraints.intervals:

digraph inheritance842c64762b { rankdir=LR; size="8.0, 12.0"; "constraints.intervals.intervals" [URL="#selectinf.constraints.intervals.intervals",fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5)",target="_top",tooltip="This class implements methods for intervals or union of two unbounded "]; }

intervals

class selectinf.constraints.intervals.intervals(I=None)[source]

Bases: object

This class implements methods for intervals or union of two unbounded intervals, when all these sets have a point in their intersection

__init__(I=None)[source]

Create a intervals object, with some unbounded and bounded intervals

Parameters

I : tuple

I is a tuple (inf, sup), the interval created

Returns

interv : intervals

The intervals object

Warning : sup has to be larger than inf. If not, it raises a

ValueError exception

If sup == inf, it creates an empty interval, and raise a Warning

>>> I = intervals()
>>> I2 = intervals((-1, 1))
static union(*interv)[source]

Return the union of all the given intervals

Parameters

interv1, … : interv

intervals instance

Returns

union, a new intervals instance, representing the union of interv1, …

>>> I = intervals.union(intervals((-np.inf, 0)),                                 intervals((-1, 1)),                                 intervals((3, 6)))
>>> print(I)

[(-inf, 1), (3, 6)]

static intersection(*interv)[source]

Return the intersection of all the given intervals

Parameters

interv1, … : interv

intervals instance

Returns

intersection, a new intervals instance, representing the intersection

of interv1, …

>>> I = intervals.intersection(intervals((-1, 6)),                                        intervals(( 0, 7)),                                        ~intervals((1, 4)))
>>> print(I)

[(0, 1), (4, 6)]