itacart.integer_index.int_parent

itacart.integer_index.int_parent(value, target_res=None)[source]

The lexical parent of an integer, by division of its position.

The arithmetic counterpart of itacart.get_parent(), and lexical in the same way: the result is the integer of the prefix one level up (or at target_res), and that prefix may name no cell. At the domain border it does not, for a child spelled under the next column’s prefix; int_to_cell() refuses it there exactly as itacart.is_valid_cell() denies the string.

Parameters:
  • value (Union[int, Iterable[int]]) – An integer of the index, or several.

  • target_res (int | None, default: None) – Resolution of the ancestor wanted. Defaults to one level up.

Return type:

int | list[int]

Returns:

The parent integer, or a list aligned with the input.

Raises:

Example

>>> int_parent(cell_to_int("NE(0625/0451(3))")) == cell_to_int("NE(0625/0451)")
True