AutoArchive._infrastructure.utils.interval

Operations with interval of integers.

Modules

interval

Interval class.

class AutoArchive._infrastructure.utils.interval.interval.Interval(min: T, max: T)[source]

Bases: Generic[T]

Interval of numbers.

Parameters:
  • min – The lower bound.

  • max – The upper bound.

property max: T

Upper bound.

property min: T

Lower bound.

interval_element

IntervalElement class.

class AutoArchive._infrastructure.utils.interval.interval_element.IntervalElement(value: int, interval: Interval[int])[source]

Bases: object

An element from a numeric interval.

It is possible to specify value outside of the defined interval. The behavior is undefined in this case.

Parameters:
  • value – The number from interval.

  • interval – The interval the value is from.

remapTo(targetInterval: Interval[int])[source]

Returns new element which is this element remapped to a target interval.

Examples:

element = 5, self.__interval = <0, 10>, targetInterval = <0, 100> => 50 element = 9, self.__interval = <1, 9>, targetInterval = <1, 19> => 19

Parameters:

targetInterval – Interval which this element shall be remapped to.

Returns:

Element from the target interval targetInterval.

property value: int

Value of the element.