Atomic

class part.Atomic(*args, **kwds)

Atomic class.

The Atomic class represents an abstract version of two concrete classes:

abstract __str__()

Return str(self).

__eq__(other)

Return self==other.

__lt__(other)

Return self<other.

__gt__(other)

Return self>other.

abstract __hash__()

Return hash(self).

abstract __bool__()

Return bool(self).

Returns

  • True – If the subset is non empty.

  • False – Otherwise.

abstract __or__(other)

Return the union of self with other.

Parameters

other (Atomic, tuple) – Another atomic subset.

Returns

The union of self and other.

Return type

FrozenIntervalSet

abstract __and__(other)

Return the intersection of self with other.

Parameters

other (Atomic, tuple) – Another atomic subset.

Returns

The intersection of self and other.

Return type

FrozenIntervalSet

abstract __sub__(other)

Return the difference of self with other.

Parameters

other (Atomic, tuple) – Another atomic subset.

Returns

The difference of self and other.

Return type

FrozenIntervalSet

abstract __xor__(other)

Return the symmetric difference of self with other.

Parameters

other (Atomic, tuple) – Another atomic subset.

Returns

The symmetric difference of self and other.

Return type

FrozenIntervalSet

abstract __invert__()

Return the complement of self.

Returns

The complement of self.

Return type

FrozenIntervalSet

static from_tuple(item)

Create an interval from a tuple.

Parameters

item (IntervalTuple) –

The tuple to transform:

  • a pair <a,b> designates an interval closed on the left and open on the right;

  • a triple <a,b,bool> designates an interval open/closed on the left and open on the right;

  • a quadruplet <a,b,bool,bool> designates an interval open/closed on the left and open/closed on the right.

Returns

  • Interval – The tuple transformed into an interval.

  • Empty – If the interval is empty

Examples

>>> from part import Atomic
>>> print(Atomic[int].from_tuple((10, 20)))
[10;20)
>>> print(Atomic[int].from_tuple((10, 20, True, None)))
[10;20)
>>> print(Atomic[int].from_tuple((10, 20, None, None)))
(10;20)
>>> print(Atomic[int].from_tuple((10, 20, None, True)))
(10;20]
static from_value(value)

Create an interval from any value.

Parameters

value (object) – The value to transform.

Returns

The value transformed into an interval containing one value.

Return type

Interval

Examples

>>> from part import Atomic
>>> print(Atomic[int].from_value(10))
[10;10]
abstract before(other, strict=True, reverse=False)

Return True if the subset is the before the other.

Parameters
  • other (Atomic) – Another atomic object.

  • strict (bool) – is the before strict?

  • reverse (bool) – is the before reversed?

Raises
abstract meets(other, strict=True, reverse=False)

Return True if the subset meets the other.

Parameters
  • other (Atomic) – Another atomic object.

  • strict (bool) – is the meets strict?

  • reverse (bool) – is the meets reversed?

Raises
abstract overlaps(other, strict=True, reverse=False)

Return True if the subset overlaps the other.

Parameters
  • other (Atomic) – Another atomic object.

  • strict (bool) – is the overlap strict?

  • reverse (bool) – is the overlaps reversed?

Raises
abstract starts(other, strict=True, reverse=False)

Return True if the subset starts the other.

Parameters
  • other (Atomic) – Another atomic object.

  • strict (bool) – is the starts strict?

  • reverse (bool) – is the starts reversed?

Raises
abstract during(other, strict=True, reverse=False)

Return True if the subset is during the other.

Parameters
  • other (Atomic) – Another atomic object.

  • strict (bool) – is the during strict?

  • reverse (bool) – is the during reversed?

Raises
abstract finishes(other, strict=True, reverse=False)

Return True if the subset finishes the other.

Parameters
  • other (Atomic) – Another atomic object.

  • strict (bool) – is the finishes strict?

  • reverse (bool) – is the finishes reversed?

Raises