Bases: Mixin
A representation of a numeric range.
This class represents a contiguous range of numbers. The class
mimics the Pyomo (not Python) range API, with a Start, End, and
Step. The Step is a signed int. If the Step is 0, the range is
continuous. The End is included in the range. Ranges are closed,
unless closed is specified as a 2-tuple of bool values. Only
continuous ranges may be open (or partially open)
Closed ranges are not necessarily strictly finite, as None is
allowed for the End value (as well as the Start value, for
continuous ranges only).
- Parameters:
start (float) – The starting value for this NumericRange
end (float) – The last value for this NumericRange
step (int) – The interval between values in the range. 0 indicates a
continuous range. Negative values indicate discrete ranges
walking backwards.
closed (tuple of bool, optional) – A 2-tuple of bool values indicating if the beginning and end
of the range is closed. Open ranges are only allowed for
continuous NumericRange objects.
-
__init__(start, end, step, closed=(True, True))[source]
Methods
__init__ (start, end, step[, closed])
|
|
isdiscrete ()
|
|
isdisjoint (other)
|
|
isfinite ()
|
|
issubset (other)
|
|
normalize_bounds ()
|
Normalizes this NumericRange. |
range_difference (other_ranges)
|
Return the difference between this range and a list of other ranges. |
range_intersection (other_ranges)
|
Return the intersection between this range and a set of other ranges. |
Attributes
Member Documentation
-
normalize_bounds()[source]
Normalizes this NumericRange.
This returns a normalized range by reversing lb and ub if the
NumericRange step is less than zero. If lb and ub are
reversed, then closed is updated to reflect that change.
- Return type:
lb, ub, closed
-
range_difference(other_ranges)[source]
Return the difference between this range and a list of other ranges.
- Parameters:
other_ranges (iterable) – An iterable of other range objects to subtract from this range
-
range_intersection(other_ranges)[source]
Return the intersection between this range and a set of other ranges.
- Parameters:
other_ranges (iterable) – An iterable of other range objects to intersect with this range