1from typing
import Union, Any
3from ids_peak_common._internal.utils
import is_equal, validate_parameter_types
4from ids_peak_common.datatypes.interval
import Interval
11 Represents a numeric range with defined boundaries and a fixed increment.
13 A Range models a continuous sequence of values starting from a minimum value,
14 ending at a maximum value, and progressing in steps defined by an increment.
15 It supports integers and floating-point numbers.
17 This class ensures that the increment does not exceed the total span between
18 the minimum and maximum bounds. The range is inclusive of its boundary values.
21 def __init__(self, minimum: Union[int, float], maximum: Union[int, float], increment: Union[int, float]):
24 Creates a range with specified minimum, maximum, and increment values.
26 @exception InvalidParameterException: If minimum is greater than maximum,
27 or if increment exceeds the total range span.
29 @param minimum: The inclusive starting (lower) boundary of the range.
30 @param maximum: The inclusive ending (upper) boundary of the range.
31 @param increment: The step size or increment between values within the range.
35 validate_parameter_types(minimum, maximum, increment, accepted_types=(int, float))
37 if increment > self.maximum - self.
minimum:
38 raise InvalidParameterException(
"The given increment is larger than the total range!")
41 def __eq__(self, other: Any) -> bool:
42 if isinstance(other, Range):
44 if isinstance(other, list)
or isinstance(other, tuple):
47 return super().
__eq__((other[0], other[1]))
and is_equal(self.
_increment, other[2])
55 Retrieves the increment value associated with this range.
62 Returns a string representation of the Range object.
64 @return String representation of the Range object.
66 return f
"(minimum={self.minimum}, maximum={self.maximum}, increment={self.increment})"
71 Return an unambiguous string of the Range object.
73 return f
"{self.__class__.__name__}{str(self)}"
Represents a numeric range with defined boundaries and a fixed increment.
Union[int, float] _increment
__init__(self, Union[int, float] minimum, Union[int, float] maximum, Union[int, float] increment)
Creates a range with specified minimum, maximum, and increment values.
str __str__(self)
Returns a string representation of the Range object.
str __repr__(self)
Return an unambiguous string of the Range object.
bool __eq__(self, Any other)
Union[int, float] increment(self)
Retrieves the increment value associated with this range.