> ## Documentation Index
> Fetch the complete documentation index at: https://docs.encord.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Objects.frames

## Range Objects

```python theme={"dark"}
@dataclass
class Range()
```

A class representing a range with a start and end value.

**Attributes**:

* `start` *int* - The starting value of the range.
* `end` *int* - The ending value of the range.

#### \_\_slots\_\_

Ranges are used heavily and are simple, so save memory

#### overlaps

```python theme={"dark"}
def overlaps(other) -> bool
```

Check if two ranges overlap

#### merge

```python theme={"dark"}
def merge(other) -> None
```

Merge another range into this one.

#### frame\_to\_range

```python theme={"dark"}
def frame_to_range(frame: int) -> Range
```

Convert a single frame to a Range.

**Arguments**:

* `frame` *int* - The single frame to be converted.

**Returns**:

* `Range` - A Range object with both start and end set to the input frame.

#### frames\_to\_ranges

```python theme={"dark"}
def frames_to_ranges(frames: Collection[int]) -> Ranges
```

Create a sorted list (in ascending order) of non-overlapping run-length encoded ranges from a collection of frames.

**Arguments**:

* `frames` *Collection\[int]* - A collection of integers representing frames.

**Returns**:

* `Ranges` - A list of Range objects representing the non-overlapping ranges.

#### ranges\_to\_list

```python theme={"dark"}
def ranges_to_list(ranges: Ranges) -> List[List[int]]
```

Convert a list of Range objects to a list of lists (run-length encoded) of integers.

**Arguments**:

* `ranges` *Ranges* - A list of Range objects.

**Returns**:

* `List[List[int]]` - A list of lists where each inner list contains two integers, the start and end of a range.

#### range\_to\_ranges

```python theme={"dark"}
def range_to_ranges(range_: Range) -> Ranges
```

Convert a single Range to a list of Ranges.

**Arguments**:

* `range_` *Range* - The single Range to be converted.

**Returns**:

* `Ranges` - A list containing the input Range as its only element.

#### range\_to\_frames

```python theme={"dark"}
def range_to_frames(range_: Range) -> List[int]
```

Convert a single Range (run-length encoded) to a list of integers.

**Arguments**:

* `range_` *Range* - The single Range to be converted.

**Returns**:

* `List[int]` - A list of integers representing the frames within the range.

#### ranges\_to\_frames

```python theme={"dark"}
def ranges_to_frames(range_list: Ranges) -> List[int]
```

Convert a list of Ranges (run-length encoded) to a list of integers.

**Arguments**:

* `range_list` *Ranges* - A list of Range objects.

**Returns**:

* `List[int]` - A sorted list of integers representing all frames within the ranges.

#### ranges\_list\_to\_ranges

```python theme={"dark"}
def ranges_list_to_ranges(range_list: List[List[int]]) -> Ranges
```

Convert a list of lists (run-length encoded) of integers to a list of Range objects.

**Arguments**:

* `range_list` *List\[List\[int]]* - A list of lists where each inner list contains two integers, the start and end of a range.

**Returns**:

* `Ranges` - A list of Range objects created from the input list of lists.

#### frames\_class\_to\_frames\_list

```python theme={"dark"}
def frames_class_to_frames_list(frames_class: Frames) -> List[int]
```

Convert a Frames class (which can be an int, a list of ints, a Range, or a list of Ranges) to a list of integers.

**Arguments**:

* `frames_class` *Frames* - A Frames class which can be a single int, a list of ints, a Range object, or a list of Range objects.

**Returns**:

* `List[int]` - A sorted list of integers representing all frames within the input Frames class.

**Raises**:

* `RuntimeError` - If the input frames\_class is of an unexpected type.
