ClosedInterval Pattern#

class paspailleur.bip.ClosedIntervalPattern(value: PatternValueType)#

A class representing a closed interval as a pattern.

This class extends IntervalPattern to specifically handle closed intervals.

Attributes#

PatternValueType :

The type of the pattern’s value, which is a tuple of two floats.

Properties#

lower_bound

Return the lower bound of the closed interval.

upper_bound

Return the upper bound of the closed interval.

is_lower_bound_closed

Check if the lower bound is closed.

is_upper_bound_closed

Check if the upper bound is closed.

PatternValueType#

alias of tuple[float, float]

property lower_bound: float#

Return the lower bound of the closed interval.

Returns:

bound – The lower bound of the closed interval.

Return type:

float

Examples

>>> ClosedIntervalPattern((1.0, 5.0)).lower_bound
1.0
property upper_bound: float#

Return the upper bound of the closed interval.

Returns:

bound – The upper bound of the closed interval.

Return type:

float

Examples

>>> ClosedIntervalPattern((1.0, 5.0)).upper_bound
5.0
property is_lower_bound_closed: bool#

Check if the lower bound is closed.

Returns:

closed – True, indicating that the lower bound is always closed.

Return type:

bool

Examples

>>> ClosedIntervalPattern((1.0, 5.0)).is_lower_bound_closed
True
property is_upper_bound_closed: bool#

Check if the upper bound is closed.

Returns:

closed – True, indicating that the upper bound is always closed.

Return type:

bool

Examples

>>> ClosedIntervalPattern((1.0, 5.0)).is_upper_bound_closed
True
classmethod parse_string_description(value: str) tuple[float, float]#

Parse a string description into a closed interval pattern value.

Parameters:

value (str) – The string description of the closed interval pattern.

Returns:

parsed – The parsed closed interval pattern value.

Return type:

PatternValueType

Raises:

AssertionError – If the bounds are not enclosed in square brackets.

Examples

>>> ClosedIntervalPattern.parse_string_description('[1,5]')
(1.0, 5.0)
classmethod preprocess_value(value) tuple[float, float]#

Preprocess the value before storing it in the closed interval pattern.

Parameters:

value – The value to preprocess.

Returns:

value – The preprocessed value as a tuple of two floats.

Return type:

PatternValueType

Raises:

ValueError – If the value cannot be preprocessed into a ClosedIntervalPattern.

Examples

>>> ClosedIntervalPattern.preprocess_value([1, 5])
(1.0, 5.0)
atomise(atoms_configuration: Literal['min', 'max'] = 'min') set[Self]#

Split the pattern into atomic patterns, i.e. the set of one-sided intervals

Parameters:

atoms_configuration (Literal['min', 'max']) – If equals to ‘min’, return up to 2 atomic patterns each representing a bound of the original interval. If equals to ‘max’, return _all_ less precise one-sided intervals, where the bounds are defined by BoundUniverse class attribute.

Returns:

atomic_patterns – The set of atomic patterns, i.e. the set of unsplittable patterns whose join equals to the pattern.

Return type:

set[Self]

Notes

Speaking in terms of Ordered Set Theory: We say that every pattern can be represented as the join of a subset of atomic patterns, that are join-irreducible elements of the lattice of all patterns.

Considering the set of atomic patterns as a partially ordered set (where the order follows the order on patterns), every pattern can be represented by an _antichain_ of atomic patterns (when atoms_configuration = ‘min’), and by an order ideal of atomic patterns (when atoms_configuration = ‘max’).