Skip to content

Define and enforce Zn symmetry input-validation semantics #771

@yingjerkao

Description

@yingjerkao

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:

  1. Zn qnums are canonical representatives in [0, n)
  2. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions