interval module#

Interval arithmetic for ranges#

This module provides the Interval class for representing ranges of values that can be bounded or unbounded on either end.

class Interval(lo=None, hi=None)[source]#

Interval Type for defining inclusive ranges of values, supporting infinite intervals. An interval may be bounded or unbounded on either end.

Parameters:
property min_value: float | None#

Returns the minimum value of the interval, or None if unbounded below.

property max_value: float | None#

Returns the maximum value of the interval, or None if unbounded above.

AtLeast(value)[source]#

Interval with unbounded maximum and bounded minimum

This is a helper function for creating a interval that is bounded from below only.

Parameters:

value (float) – Inclusive low end bound for the interval

Return type:

Interval

>>> AtLeast(1)
Interval(1, None)
AtMost(value)[source]#

Interval with unbounded minimum and bounded maximum

This is a helper function for creating a interval that is bounded from above only.

Parameters:

value (float) – Inclusive high end bound for the interval

Return type:

Interval

>>> AtMost(2)
Interval(None, 2)