random_events.interval
======================

.. py:module:: random_events.interval


Classes
-------

.. autoapisummary::

   random_events.interval.Bound
   random_events.interval.SimpleInterval
   random_events.interval.Interval


Functions
---------

.. autoapisummary::

   random_events.interval.open
   random_events.interval.closed
   random_events.interval.open_closed
   random_events.interval.closed_open
   random_events.interval.singleton
   random_events.interval.reals


Module Contents
---------------

.. py:class:: Bound

   Bases: :py:obj:`enum.IntEnum`


   Enumerates the possible bounds for an interval.


   .. py:attribute:: CLOSED
      :value: 0


      Represents a closed bound, i. e. the element is included from the interval.



   .. py:attribute:: OPEN
      :value: 1


      Represents an open bound, i. e. the element is excluded in the interval.



.. py:class:: SimpleInterval(lower: float = 0, upper: float = 0, left: Bound = Bound.OPEN, right: Bound = Bound.OPEN)

   Bases: :py:obj:`random_events.sigma_algebra.AbstractSimpleSet`


   A simple interval.
   A simple interval is the convex hull of two points.


   .. py:attribute:: _cpp_object
      :type:  random_events_lib.SimpleInterval

      The C++ object that this class wraps.



   .. py:property:: lower
      :type: float


      :return: The lower bound of the interval.



   .. py:property:: upper
      :type: float


      :return: The upper bound of the interval.



   .. py:property:: left
      :type: Bound


      :return: The bound type of the lower bound.



   .. py:property:: right
      :type: Bound


      :return: The bound type of the upper bound.



   .. py:method:: _from_cpp(cpp_object: random_events_lib.SimpleInterval) -> typing_extensions.Self
      :classmethod:


      Create a new instance of this class from a C++ object.

      This method should also add fields that are python only to the instance that is created.
      This cannot be a class method since the values of the python-only fields are instance-specific.



   .. py:method:: as_composite_set() -> Interval

      Convert this simple set to a composite set.

      :return: The composite set



   .. py:method:: is_singleton() -> bool

      # TODO: fix this when random_events_lib is fixed
      :return: True if the interval is a singleton (contains only one value), False otherwise.



   .. py:method:: contains(item: float) -> bool

      Check if this set contains an item.
      :param item: The item to check
      :return: Rather if the item is in the set or not



   .. py:method:: non_empty_to_string() -> str

      :return: A string representation of this set if it is not empty.



   .. py:method:: to_json() -> Dict[str, Any]


   .. py:method:: _from_json(data: Dict[str, Any]) -> typing_extensions.Self
      :classmethod:


      Create a variable from a json dict.
      This method is called from the from_json method after the correct subclass is determined and should be
      overwritten by the respective subclass.

      :param data: The json dict
      :return: The deserialized object



   .. py:method:: center() -> float

      :return: The center point of the interval



   .. py:method:: contained_integers() -> typing_extensions.Iterable[int]

      :return: Yield integers contained in the interval



   .. py:method:: __deepcopy__()


.. py:class:: Interval(*simple_sets)

   Bases: :py:obj:`random_events.sigma_algebra.AbstractCompositeSet`


   Represents an interval.

   An interval is a union of simple intervals.

   A simplified interval is an interval where adjacent simple intervals are merged.


   .. py:attribute:: _cpp_object
      :type:  random_events_lib.Interval

      The C++ object that this class wraps.



   .. py:attribute:: simple_set_example

      An example of a simple set that is used to create new simple sets. 
      Fields that are python only are read from this instance when reading from cpp.



   .. py:method:: _from_cpp(cpp_object: random_events_lib.Interval) -> typing_extensions.Self
      :classmethod:


      Create a new instance of this class from a C++ object.

      This method should also add fields that are python only to the instance that is created.
      This cannot be a class method since the values of the python-only fields are instance-specific.



   .. py:method:: is_singleton()

      :return: True if the interval is a singleton (contains only one value), False otherwise.



   .. py:method:: contained_integers() -> typing_extensions.Iterable[int]

      :return: Yield integers contained in the interval



.. py:function:: open(left: float, right: float) -> Interval

   Creates an open interval.

   :param left: The left bound of the interval.
   :param right: The right bound of the interval.
   :return: The open interval.


.. py:function:: closed(left: float, right: float) -> Interval

   Creates a closed interval.

   :param left: The left bound of the interval.
   :param right: The right bound of the interval.
   :return: The closed interval.


.. py:function:: open_closed(left: float, right: float) -> Interval

   Creates an open-closed interval.

   :param left: The left bound of the interval.
   :param right: The right bound of the interval.
   :return: The open-closed interval.


.. py:function:: closed_open(left: float, right: float) -> Interval

   Creates a closed-open interval.

   :param left: The left bound of the interval.
   :param right: The right bound of the interval.
   :return: The closed-open interval.


.. py:function:: singleton(value: float) -> Interval

   Creates a singleton interval.

   :param value: The value of the interval.
   :return: The singleton interval.


.. py:function:: reals() -> Interval

   Creates the set of real numbers.

   :return: The set of real numbers.


