Interval

class baybe.utils.interval.Interval[source]

Bases: SerialMixin

Intervals on the real number line.

Public methods

__init__(lower, upper)

Method generated by attrs for class Interval.

contains(number)

Check whether the interval contains a given number.

create(value)

Create an interval from various input types.

from_dict(dictionary)

Create an object from its dictionary representation.

from_json(string)

Create an object from its JSON representation.

to_dict()

Create an object's dictionary representation.

to_json()

Create an object's JSON representation.

to_ndarray()

Transform the interval to a numpy.ndarray.

to_tensor()

Transform the interval to a torch.Tensor.

to_tuple()

Transform the interval to a tuple.

Public attributes and properties

lower

The lower end of the interval.

upper

The upper end of the interval.

center

The center of the interval, or None if the interval is unbounded.

is_bounded

Check if the interval is bounded.

is_finite

Check whether the interval is finite.

is_fully_unbounded

Check if the interval represents the entire real number line.

is_half_bounded

Check if the interval is half-bounded.

is_left_bounded

Check if the interval is left-bounded.

is_right_bounded

Check if the interval is right-bounded.

__init__(lower, upper)

Method generated by attrs for class Interval.

For details on the parameters, see Public attributes and properties.

contains(number: float)[source]

Check whether the interval contains a given number.

Parameters:

number (float) – The number that should be checked.

Return type:

bool

Returns:

Whether or not the interval contains the number.

classmethod create(value: Any)[source]

Create an interval from various input types.

classmethod from_dict(dictionary: dict)

Create an object from its dictionary representation.

Parameters:

dictionary (dict) – The dictionary representation.

Return type:

TypeVar(_T)

Returns:

The reconstructed object.

classmethod from_json(string: str)

Create an object from its JSON representation.

Parameters:

string (str) – The JSON representation of the object.

Return type:

TypeVar(_T)

Returns:

The reconstructed object.

to_dict()

Create an object’s dictionary representation.

Return type:

dict

to_json()

Create an object’s JSON representation.

Return type:

str

Returns:

The JSON representation as a string.

to_ndarray()[source]

Transform the interval to a numpy.ndarray.

Return type:

ndarray

to_tensor()[source]

Transform the interval to a torch.Tensor.

Return type:

Tensor

to_tuple()[source]

Transform the interval to a tuple.

Return type:

tuple[float, float]

property center: float | None

The center of the interval, or None if the interval is unbounded.

property is_bounded: bool

Check if the interval is bounded.

property is_finite: bool

Check whether the interval is finite.

property is_fully_unbounded: bool

Check if the interval represents the entire real number line.

property is_half_bounded: bool

Check if the interval is half-bounded.

property is_left_bounded: bool

Check if the interval is left-bounded.

property is_right_bounded: bool

Check if the interval is right-bounded.

lower: float

The lower end of the interval.

upper: float

The upper end of the interval.