Bases: Bound
A closed Bound, i.e. the value on the border belongs to the range.
Parameters:
Name |
Type |
Description |
Default |
value |
float
|
|
required
|
Source code in src/safeds/exceptions/_generic.py
| class ClosedBound(Bound):
"""
A closed Bound, i.e. the value on the border belongs to the range.
Parameters
----------
value: float
The value of the Bound.
"""
def __init__(self, value: float):
"""
Initialize a ClosedBound.
Parameters
----------
value: float
The value of the ClosedBound.
Raises
------
ValueError
If value is nan or if value is +/-inf.
"""
if value == float("-inf") or value == float("inf"):
raise ValueError("ClosedBound must be a real number, not +/-inf.")
super().__init__(value)
def _str_lower_bound(self) -> str:
"""Get a string representation of the ClosedBound as the lower Bound of an interval."""
return f"[{self}"
def _str_upper_bound(self) -> str:
"""Get a string representation of the ClosedBound as the upper Bound of an interval."""
return f"{self}]"
def _check_lower_bound(self, actual: float) -> bool:
"""
Check that a value is not strictly lower than the ClosedBound.
Parameters
----------
actual: float
The actual value that should be checked for not exceeding the Bound.
"""
return actual >= self.value
def _check_upper_bound(self, actual: float) -> bool:
"""
Check that a value is not strictly higher than the ClosedBound.
Parameters
----------
actual: float
The actual value that should be checked for not exceeding the Bound.
"""
return actual <= self.value
|
__init__(value)
Initialize a ClosedBound.
Parameters:
Name |
Type |
Description |
Default |
value |
float
|
The value of the ClosedBound.
|
required
|
Raises:
Type |
Description |
ValueError
|
If value is nan or if value is +/-inf.
|
Source code in src/safeds/exceptions/_generic.py
| def __init__(self, value: float):
"""
Initialize a ClosedBound.
Parameters
----------
value: float
The value of the ClosedBound.
Raises
------
ValueError
If value is nan or if value is +/-inf.
"""
if value == float("-inf") or value == float("inf"):
raise ValueError("ClosedBound must be a real number, not +/-inf.")
super().__init__(value)
|