Skip to content

Types and helpers

pbcgraph.core.types

Core types and translation-vector helpers.

The public API uses a small number of lightweight aliases:

Attributes:

Name Type Description
TVec

Integer translation vector (length dim).

NodeId

Hashable quotient-node identifier.

EdgeKey

Integer key identifying a directed edge in a multigraph.

NodeInst

Node instance in the infinite lift: (node_id, shift).

TVec module-attribute

TVec = Tuple[int, ...]

NodeId module-attribute

NodeId = Hashable

EdgeKey module-attribute

EdgeKey = int

NodeInst module-attribute

NodeInst = Tuple[NodeId, TVec]

zero_tvec

zero_tvec(dim: int) -> TVec

Return the zero translation vector of length dim.

validate_tvec

validate_tvec(tvec: Any, dim: int) -> None

Validate that tvec is an integer translation vector of dimension dim.

Accepts
  • tuples/lists of integer-likes,
  • 1D NumPy arrays,
  • sequences containing NumPy integer scalars.

Parameters:

Name Type Description Default
tvec Any

Translation vector.

required
dim int

Required dimension.

required

Raises:

Type Description
ValueError

If tvec has wrong length, wrong shape, or non-integer entries.

Notes
  • Entries must be instances of :class:numbers.Integral.
  • bool is rejected (even though it is a subclass of int).
  • This function validates only; containers store translation vectors internally as tuples of Python int.

add_tvec

add_tvec(a: TVec, b: TVec) -> TVec

Add two translation vectors.

sub_tvec

sub_tvec(a: TVec, b: TVec) -> TVec

Subtract two translation vectors.

neg_tvec

neg_tvec(a: TVec) -> TVec

Negate a translation vector.