symop.ccr.common

Common CCR utilities.

Shared helpers, signatures, and key definitions used across CCR-related modules.

sig_density(t: DensityTerm, *, approx: bool = False, decimals: int = 12, ignore_global_phase: bool = False) tuple[object, ...]

Return an exact or approximate signature for a density term.

Parameters:
  • t (DensityTerm) – A density-term-like object that provides the attribute signature and the method approx_signature(decimals=..., ignore_global_phase=...).

  • approx (bool) – If True, return t.approx_signature(...). If False, return t.signature.

  • decimals (int) – Number of decimals to round to (forwarded to approx_signature).

  • ignore_global_phase (bool) – If True, treat global phase parameters as zero for grouping (forwarded to approx_signature).

Returns:

A hashable signature tuple suitable for use as a dictionary key.

Return type:

SignatureProto

sig_ket(t: KetTerm, *, approx: bool = False, decimals: int = 12, ignore_global_phase: bool = False) tuple[object, ...]

Return an exact or approximate signature for a ket term.

Parameters:
  • t (KetTerm) – A ket-term-like object that provides the attribute signature and the method approx_signature(decimals=..., ignore_global_phase=...).

  • approx (bool) – If True, return t.approx_signature(...). If False, return t.signature.

  • decimals (int) – Number of decimals to round to (forwarded to approx_signature).

  • ignore_global_phase (bool) – If True, treat global phase parameters as zero for grouping (forwarded to approx_signature).

Returns:

A hashable signature tuple suitable for use as a dictionary key.

Return type:

SignatureProto

sig_lop(op: HasSignature, *, approx: bool = False, decimals: int = 12, ignore_global_phase: bool = False) tuple[object, ...]

Return an exact or approximate key for a ladder operator.

Parameters:
  • op (HasSignature) – A ladder-operator-like object with signature and approx_signature(decimals=..., ignore_global_phase=...).

  • approx (bool) – If True, return op.approx_signature(...). If False, return op.signature.

  • decimals (int) – Number of decimals to round to (forwarded to approx_signature).

  • ignore_global_phase (bool) – If True, treat global phase parameters as zero for grouping (forwarded to approx_signature).

Returns:

Hashable ladder-operator key.

Return type:

SignatureProto

Notes

This function exists mostly for readability. It is equivalent to sig_obj() but communicates intent at call sites.

sig_mono(m: Monomial, *, approx: bool = False, decimals: int = 12, ignore_global_phase: bool = False) tuple[object, ...]

Return an exact or approximate signature for a monomial.

Parameters:
  • m (Monomial) – A monomial-like object that provides the attribute signature and the method approx_signature(decimals=..., ignore_global_phase=...).

  • approx (bool) – If True, return m.approx_signature(...). If False, return m.signature.

  • decimals (int) – Number of decimals to round to (forwarded to approx_signature).

  • ignore_global_phase (bool) – If True, treat global phase parameters as zero for grouping (forwarded to approx_signature).

Returns:

A hashable signature tuple suitable for use as a dictionary key.

Return type:

SignatureProto

sig_obj(obj: HasSignature, *, approx: bool = False, decimals: int = 12, ignore_global_phase: bool = False) tuple[object, ...]

Return an exact or approximate key for a signature-bearing object.

Parameters:
  • obj (HasSignature) – Any object that provides signature and approx_signature(decimals=..., ignore_global_phase=...).

  • approx (bool) – If True, return obj.approx_signature(...). If False, return obj.signature.

  • decimals (int) – Number of decimals to round to (forwarded to approx_signature).

  • ignore_global_phase (bool) – If True, treat global phase parameters as zero for grouping (forwarded to approx_signature).

Returns:

A hashable signature tuple suitable for use as a dictionary key.

Return type:

SignatureProto

sig_word(ops: Iterable[HasSignature], *, approx: bool = False, decimals: int = 12, ignore_global_phase: bool = False) tuple[tuple[object, ...], ...]

Return a key for an operator word (ordered product of ladder operators).

Parameters:
  • ops (Iterable[HasSignature]) – Iterable of ladder operators defining a word. The iterable is materialized into a tuple to make the key stable and hashable.

  • approx (bool) – If True, each operator key is taken from approx_signature(...). If False, each operator key is taken from signature.

  • decimals (int) – Number of decimals to round to (forwarded to each approx_signature).

  • ignore_global_phase (bool) – If True, treat global phase parameters as zero for grouping (forwarded to each approx_signature).

Returns:

Hashable key representing the ordered operator word.

Return type:

tuple[SignatureProto, …]

Modules

keys

Key helpers for CCR algebra canonicalization.

signatures

Signature helpers for CCR algebra canonicalization.