itacart.topology.grid_disk

itacart.topology.grid_disk(index, k_distance=1, metric='chebyshev', dedupe=False, flatten=False)[source]

Cells within k grid steps of the origin, the origin included.

chebyshev admits diagonal steps, giving a filled rhombus on the lattice; manhattan admits only axis steps, giving a filled diamond. In the interior the unit disks hold nine and five cells respectively.

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

  • k_distance (int, default: 1) – Ring radius in grid steps.

  • metric (Literal['chebyshev', 'manhattan'], default: "chebyshev") – Lattice metric to expand under.

  • dedupe (bool, default: False) – When the input holds several cells, drop cells that appear in more than one disk. Breaks positional alignment, so it is off by default.

  • flatten (bool, default: False) – When the input holds several cells, False returns one list per input cell; True returns a single flat list.

Return type:

list[str] | list[list[str]]

Returns:

A cell list for a single origin, or a list of lists aligned with itacart.index.decompose().

Raises:
  • ValueError – If k_distance is negative or metric is unknown.

  • DomainError – If the disk reaches the geometric exception set, where a direction is multivalued and composing steps would lose cells silently.

  • NonExistentCellError – If any cell of the index names no cell. The predicate is the arbiter and the contract ends there: a spelling it denies is refused rather than answered for the cell it would otherwise fold onto.