Skip to content

OpenBound

Bases: Bound

An open Bound, i.e. the value on the border does not belong to the range.

Parameters:

Name Type Description Default
value float

The value of the OpenBound.

required
Source code in src/safeds/exceptions/_generic.py
class OpenBound(Bound):
    """
    An open Bound, i.e. the value on the border does not belong to the range.

    Parameters
    ----------
    value: float
        The value of the OpenBound.
    """

    def __init__(self, value: float):
        """
        Initialize an OpenBound.

        Parameters
        ----------
        value: float
            The value of the OpenBound.

        Raises
        ------
        ValueError
            If value is nan.
        """
        super().__init__(value)

    def __str__(self) -> str:
        """Get a string representation of the concrete value of the OpenBound."""
        if self.value == float("-inf"):
            return "-\u221e"
        elif self.value == float("inf"):
            return "\u221e"
        else:
            return super().__str__()

    def _str_lower_bound(self) -> str:
        """Get a string representation of the OpenBound as the lower Bound of an interval."""
        return f"({self}"

    def _str_upper_bound(self) -> str:
        """Get a string representation of the OpenBound as the upper Bound of an interval."""
        return f"{self})"

    def _check_lower_bound(self, actual: float) -> bool:
        """
        Check that a value is not lower or equal to the OpenBound.

        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 higher or equal to the OpenBound.

        Parameters
        ----------
        actual: float
            The actual value that should be checked for not exceeding the Bound.
        """
        return actual < self.value

__init__(value)

Initialize an OpenBound.

Parameters:

Name Type Description Default
value float

The value of the OpenBound.

required

Raises:

Type Description
ValueError

If value is nan.

Source code in src/safeds/exceptions/_generic.py
def __init__(self, value: float):
    """
    Initialize an OpenBound.

    Parameters
    ----------
    value: float
        The value of the OpenBound.

    Raises
    ------
    ValueError
        If value is nan.
    """
    super().__init__(value)

__str__()

Get a string representation of the concrete value of the OpenBound.

Source code in src/safeds/exceptions/_generic.py
def __str__(self) -> str:
    """Get a string representation of the concrete value of the OpenBound."""
    if self.value == float("-inf"):
        return "-\u221e"
    elif self.value == float("inf"):
        return "\u221e"
    else:
        return super().__str__()