symop.ccr.common.signatures¶
Signature helpers for CCR algebra canonicalization.
This module provides small helpers that extract exact or approximate signatures from algebraic atoms (monomials, ket terms, density terms).
These signatures are intended to be used as stable, hashable keys in canonicalization routines such as “combine like terms”.
Exact vs approximate¶
Many objects in the CCR layer expose two related notions of identity:
signature: exact structural identity (stable, hashable).approx_signature(decimals=..., ignore_global_phase=...): identity up to an approximation scheme based on rounding floating parameters and (optionally) ignoring global phase.
This module standardizes the selection logic:
Notes
This file is intentionally dependency-light and should remain stable, since it sits at the bottom of the CCR dependency tree.
Functions
|
Return an exact or approximate signature for a density term. |
|
Return an exact or approximate signature for a ket term. |
|
Return an exact or approximate signature for a monomial. |
- 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 attributesignatureand the methodapprox_signature(decimals=..., ignore_global_phase=...).approx (
bool) – IfTrue, returnt.approx_signature(...). IfFalse, returnt.signature.decimals (
int) – Number of decimals to round to (forwarded toapprox_signature).ignore_global_phase (
bool) – IfTrue, treat global phase parameters as zero for grouping (forwarded toapprox_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 attributesignatureand the methodapprox_signature(decimals=..., ignore_global_phase=...).approx (
bool) – IfTrue, returnt.approx_signature(...). IfFalse, returnt.signature.decimals (
int) – Number of decimals to round to (forwarded toapprox_signature).ignore_global_phase (
bool) – IfTrue, treat global phase parameters as zero for grouping (forwarded toapprox_signature).
- Returns:
A hashable signature tuple suitable for use as a dictionary key.
- Return type:
SignatureProto
- 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 attributesignatureand the methodapprox_signature(decimals=..., ignore_global_phase=...).approx (
bool) – IfTrue, returnm.approx_signature(...). IfFalse, returnm.signature.decimals (
int) – Number of decimals to round to (forwarded toapprox_signature).ignore_global_phase (
bool) – IfTrue, treat global phase parameters as zero for grouping (forwarded toapprox_signature).
- Returns:
A hashable signature tuple suitable for use as a dictionary key.
- Return type:
SignatureProto