The current Zn symmetry API has mixed semantics around valid quantum numbers.
Current behavior
check_qnum and check_qnums define valid Zn qnums as canonical values in [0, n)
Bond construction enforces that same canonical range
- but the public arithmetic API (
combine_rule / reverse_rule) historically accepts wider integer inputs instead of rejecting out-of-range values first
This means the API currently mixes two models:
- Zn qnums are canonical representatives in
[0, n)
- Zn qnums are arbitrary integers modulo
n
PR #768 fixes the narrower correctness bug that public arithmetic should return canonical outputs in [0, n), but it does not change the broader input policy.
Follow-up question
Decide whether the public Zn arithmetic API should:
- continue accepting wider integer inputs and normalize internally, or
- reject out-of-range Zn inputs as invalid API usage
Why this needs a separate issue
- changing input rejection would be a behavior change, not just a bug fix
- it may affect existing call sites that currently rely on modulo-style inputs
- the decision should be applied consistently across
check_qnum, combine_rule, reverse_rule, and Bond-facing APIs
Likely work if rejection is chosen
- audit current call sites for out-of-range Zn inputs
- decide whether scalar and vector overloads should both reject
- add explicit tests for accepted vs rejected Zn inputs
- document the intended Zn API contract clearly
The current
Znsymmetry API has mixed semantics around valid quantum numbers.Current behavior
check_qnumandcheck_qnumsdefine valid Zn qnums as canonical values in[0, n)Bondconstruction enforces that same canonical rangecombine_rule/reverse_rule) historically accepts wider integer inputs instead of rejecting out-of-range values firstThis means the API currently mixes two models:
[0, n)nPR #768 fixes the narrower correctness bug that public arithmetic should return canonical outputs in
[0, n), but it does not change the broader input policy.Follow-up question
Decide whether the public Zn arithmetic API should:
Why this needs a separate issue
check_qnum,combine_rule,reverse_rule, and Bond-facing APIsLikely work if rejection is chosen