itacart.intervals.cells_to_intervals

itacart.intervals.cells_to_intervals(index, resolution=None)[source]

The region an index names, as an interval list.

Parameters:
  • index (str) – Compositional index string.

  • resolution (int | None, default: None) – Depth of the list. Defaults to the finest resolution the index holds. A cell coarser than it stands for its physical descendants at it.

Return type:

list[tuple[int, int]]

Returns:

The canonical interval list – sorted, disjoint, no two touching.

Raises:
  • InvalidIndexError – If the index is malformed.

  • NonExistentCellError – If any cell of the index names no cell.

  • ResolutionError – If resolution is outside 0 to 13, or coarser than a cell of the index, or if a quadrant is to be expanded: its descendants are the resolution-1 lattice, which the hierarchy does not enumerate either.

  • GeometryError – If the expansion reaches the cell that holds a pole at resolution 10, whose children cannot be enumerated: the cells found leave part of its ring uncovered. A known limitation, stated in itacart.hierarchy.

Example

>>> from itacart import cell_to_int
>>> cells_to_intervals("NE(0625/0451(1))", resolution=3) == [
...     (cell_to_int("NE(0625/0451(1(A1)))"),
...      cell_to_int("NE(0625/0451(1(E5)))") + 1)]
True