verry.interval.Interval#

class verry.interval.Interval(inf=None, sup=None)#

Bases: Scalar, ABC, Generic

Abstract base class for inf-sup type intervals.

Parameters:
  • inf (endtype | float | int | str | None, optional) – Infimum of the interval.

  • sup (endtype | float | int | str | None, optional) – Supremum of the interval.

Variables:
  • inf (endtype) – Infimum of the interval.

  • sup (endtype) – Supremum of the interval.

  • endtype (type) – Type of endpoints.

  • converter (Converter)

  • operator (Operator)

Notes

endtype, converter, and operator must be class constants.

classmethod ensure(value)#

Convert value to an interval and return its copy.

copy()#

Return a shallow copy of the interval.

diam()#

Return an upper bound of the diameter.

Warning

x.diam() might not be finite even if x is bounded.

See also

isbounded

Examples

>>> from verry import FloatInterval
>>> x = FloatInterval(-1, 1)
>>> x.diam()
2.0
>>> y = 1e+308 * x
>>> y.isbounded()
True
>>> y.diam()  # results in a positive infinity due to overflow.
inf
hull(*args)#

Return an interval hull.

interiorcontains(other)#

Return True if the interior of the interval contains other.

isbounded()#

Return True if both inf and sup are finite.

isdisjoint(other)#

Return True if the interval has no elements in common with other.

issubset(other)#

Test whether every element in the interval is in other.

issuperset(other)#

Test whether every element in other is in the interval.

mag()#

Return a magnitude of the interval.

The magnitude of x is defined as max(abs(x.inf), abs(x.sup)).

abstractmethod mid()#

Return an approximation of the midpoint.

x.mid() in x is guaranteed to be True for any x.

mig()#

Return a mignitude of the interval.

The mignitude of x is defined as min(abs(x.inf), abs(x.sup)).

rad()#

Return an upper bound of the radius.

width()#

Alias of diam().