Skip to main content

racah-py

AI-generated, for agentic coding. This document was written by an AI agent as reference material for AI agents (and humans) working on this repository. It may contain errors — check it against the code and tests rather than trusting it blindly.

Python bindings (PyO3 + maturin) for the racah crate. racah is the coefficient authority behind TeNeT-py's symmetry providers; this package is how that consumer (and any other Python code) reaches it.

Two surfaces:

  • SU(N), taking Irrep labels and running the generated Gelfand–Tsetlin pipeline — irreps from Dynkin labels, fusion with outer multiplicities, dense m-basis Clebsch–Gordan tensors, F/R symbols with their multiplicity axes, and the verification gates.
  • exact SU(2), taking doubled integer spins and returning scalars from closed-form big-rational arithmetic — wigner_3j, wigner_6j, su2_clebsch_gordan, su2_f_symbol, su2_r_symbol, su2_frobenius_schur.

SU(2) is reachable through either (Irrep([2j]) is a rank-1 label), and they are separate authorities with separate fingerprints. They agree on F and R and differ on the Clebsch–Gordan coefficients by one sign per fusion channel — see "Versioning and the gauge fingerprint" below.

Import name is racah; the distribution is racah-py. Wheels are always built with the crate's cgc-gen feature on, so the generated coefficients are available out of the box. CGC/F/R arrays come back as NumPy float64 arrays.

Installation

From PyPI (Python ≥ 3.12; prebuilt abi3 wheels for linux-x86_64 and macos-arm64):

pip install racah-py

Or from a checkout (needs a Rust stable toolchain):

git clone https://github.com/Ryo-wtnb11/racah
cd racah/racah-py
python -m venv .venv && . .venv/bin/activate
pip install maturin
maturin develop --release          # builds the extension into the active venv

or build a wheel and install it anywhere:

maturin build --release --manifest-path racah-py/Cargo.toml --out dist
pip install --no-index --find-links dist racah-py

CI (wheels.yml) builds abi3-py312 wheels for linux-x86_64 and macos-arm64; py-v* tags/releases publish them to PyPI. One wheel per platform covers CPython ≥ 3.12.

Quick start

Verified against the built extension; every call below is the actual API (see racah.pyi for the full typed surface).

import racah

three = racah.Irrep([1, 0])            # SU(3) fundamental, from its Dynkin label
assert three.dim() == 3                # exact integer, arbitrary precision
eight = racah.Irrep([1, 1])            # the adjoint

# Fusion: 3 x 3bar = 1 + 8, and the adjoint appears twice in 8 x 8.
assert racah.fusion(three, three.dual()) == [
    (racah.Irrep([0, 0]), 1),
    (eight, 1),
]
assert racah.fusion_multiplicity(eight, eight, eight) == 2  # N^8_88

# m-basis Clebsch-Gordan tensor: [dim(s1), dim(s2), dim(s3), N^{s3}_{s1 s2}].
cgc = racah.clebsch_gordan(three, three.dual(), eight)
assert cgc.shape == (3, 3, 8, 1)

# F-symbol block over the four multiplicity indices [mu, nu, kappa, lambda].
f = racah.f_symbol(eight, eight, eight, eight, eight, eight)
assert f.shape == (2, 2, 2, 2)

# R-symbol multiplicity matrix, N^c_ab x N^c_ba.
r = racah.r_symbol(three, three.dual(), eight)
assert r.shape == (1, 1)

# The verification gates raise RuntimeError on violation.
racah.check_pentagon(three, three.dual(), three, three.dual())

# The gauge fingerprint a consumer pins next to persisted coefficients.
print(racah.sun_authority_fingerprint())

The exact SU(2) surface takes doubled labels (dj = 2j, dm = 2m), so every label stays an exact integer:

import racah

assert abs(racah.wigner_6j(2, 2, 2, 2, 2, 2) - 1 / 6) < 1e-14
assert racah.su2_r_symbol(1, 1, 0) == -1.0        # (-1)^(1/2 + 1/2 - 0)
assert racah.su2_r_symbol(1, 1, 4) == 0.0         # inadmissible is exact zero,
                                                  # not an error
print(racah.su2_authority_fingerprint())

Reaching the same R-symbol through r_symbol(Irrep([1]), Irrep([1]), Irrep([0])) builds a Clebsch–Gordan tensor first; su2_r_symbol is a sign.

The rest of the surface: Irrep.from_weight / Irrep.trivial constructors, the dynkin / weight / rank properties, and check_f_unitarity and check_hexagon alongside check_pentagon.

Ill-posed input (bad label, mixed rank, empty fusion vertex) raises ValueError; a tripped numerical gate (orthonormality, F-unitarity, pentagon, hexagon, factorization failure) raises RuntimeError.

Versioning and the gauge fingerprint

F/R/CGC values depend on the CGC gauge; racah publishes them in one frozen canonical gauge. racah.sun_authority_fingerprint() returns the opaque authority string identifying that convention, generation pipeline, and tolerance policy — TeNeT-py pins it next to persisted coefficients and refuses a mismatch on load. Compare it by equality only; a breaking coefficient change bumps the fingerprint epoch and is recorded in the CHANGELOG. Same fingerprint means same convention and value agreement within the oracle tolerance, not cross-process bit-identity (docs.rs: sun_authority_fingerprint).

racah.su2_authority_fingerprint() is its twin for the exact SU(2) surface, and the two are different strings on purpose. Numerical agreement is not authority identity: F-symbols and R-symbols do agree between the tiers to round-off, but their Clebsch–Gordan coefficients differ by exactly one sign per fusion channel, uniform in the magnetic indices and equal to su2_r_symbol itself. F and R are gauge-invariant combinations in which that phase cancels; CGC are gauge data. Mixing the two tiers' CGC without the factor gives wrong signs and no error, so record the fingerprint of whichever surface produced what you persisted.

Documentation

The semantics are the crate's; the bindings add nothing:

  • User Guide — task-oriented chapters; shapes and axis conventions match the arrays returned here.
  • docs/theory.pdf — the mathematics behind the objects.
  • docs/gauge.md — the frozen SU(N) gauge specification the fingerprint names.
  • docs.rs/racah — exact per-item semantics and errors.
  • docs/README.md — the full documentation index.

Development

uv venv && uv pip install maturin pytest numpy
cd racah-py && maturin develop --release
pytest tests

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

racah_py-0.1.2.tar.gz (3.8 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

racah_py-0.1.2-cp312-abi3-win_amd64.whl (15.0 MB view details)

Uploaded CPython 3.12+Windows x86-64

racah_py-0.1.2-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (13.3 MB view details)

Uploaded CPython 3.12+manylinux: glibc 2.17+ x86-64

racah_py-0.1.2-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (12.2 MB view details)

Uploaded CPython 3.12+manylinux: glibc 2.17+ ARM64

racah_py-0.1.2-cp312-abi3-macosx_11_0_arm64.whl (12.7 MB view details)

Uploaded CPython 3.12+macOS 11.0+ ARM64

racah_py-0.1.2-cp312-abi3-macosx_10_12_x86_64.whl (14.6 MB view details)

Uploaded CPython 3.12+macOS 10.12+ x86-64

File details

Details for the file racah_py-0.1.2.tar.gz.

File metadata

  • Download URL: racah_py-0.1.2.tar.gz
  • Upload date:
  • Size: 3.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for racah_py-0.1.2.tar.gz
Algorithm Hash digest
SHA256 b2d85bfde8379d3684f42939316dfd5e01622a1ea4176d30e68b595e54664ab6
MD5 9fe55c0a5cad3074117ef413006de236
BLAKE2b-256 08cf700b8c7c7dd7a13657b810e7cc547909edad882ea868ecedd6f496573804

See more details on using hashes here.

Provenance

The following attestation bundles were made for racah_py-0.1.2.tar.gz:

Publisher: wheels.yml on Ryo-wtnb11/racah

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file racah_py-0.1.2-cp312-abi3-win_amd64.whl.

File metadata

  • Download URL: racah_py-0.1.2-cp312-abi3-win_amd64.whl
  • Upload date:
  • Size: 15.0 MB
  • Tags: CPython 3.12+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for racah_py-0.1.2-cp312-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 10817576b517b9dba3864a7ad9b4054a98252d18e313edc1a1bbe81e8c5ec7a2
MD5 32d6b4e3703676c63228530631e70fc3
BLAKE2b-256 96020e0889a715c7cdf471a4c994accfe91ca277964ba92ac70edf6491b4caaf

See more details on using hashes here.

Provenance

The following attestation bundles were made for racah_py-0.1.2-cp312-abi3-win_amd64.whl:

Publisher: wheels.yml on Ryo-wtnb11/racah

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file racah_py-0.1.2-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for racah_py-0.1.2-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d925b85d83a72aec0d7b84c024ae13dd35598b2edc29fce21df48ee19fd1c83a
MD5 bc1d7684e9a69bb9a1f8a420e12ae056
BLAKE2b-256 4a596ccd7fec24f373be2a9c8a3eaef06830ae085b856c708c028fdc7fa867c5

See more details on using hashes here.

Provenance

The following attestation bundles were made for racah_py-0.1.2-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: wheels.yml on Ryo-wtnb11/racah

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file racah_py-0.1.2-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for racah_py-0.1.2-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 411afcc72dcfafd4b52a7e4236d9acadb6fdedbc1f9937c3fa17a28d63cb9bb6
MD5 b371ded007904b74edcf31ef60dbf665
BLAKE2b-256 e559aa557034854637d57a351b626c82405b277db54f533d6d5efec77c42f072

See more details on using hashes here.

Provenance

The following attestation bundles were made for racah_py-0.1.2-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: wheels.yml on Ryo-wtnb11/racah

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file racah_py-0.1.2-cp312-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for racah_py-0.1.2-cp312-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a0d7cbd4f78fdf4f2e8913ff83b1ac78aa398d00bb55f1c03b07846071cbccdf
MD5 5df783c298510ca677879a4353573097
BLAKE2b-256 b77878ee34f90dec85056365f4ed12fa27da86c5c37af102361945575fe613d7

See more details on using hashes here.

Provenance

The following attestation bundles were made for racah_py-0.1.2-cp312-abi3-macosx_11_0_arm64.whl:

Publisher: wheels.yml on Ryo-wtnb11/racah

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file racah_py-0.1.2-cp312-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for racah_py-0.1.2-cp312-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 f844b4b23314dd7450b83c51ba9a8538f585cb19b91193cfb39d0dc4e09cec35
MD5 adcf0dd1b7ae980efdb59ea35e250949
BLAKE2b-256 04b03a8ba2786dd82d16c8dbc32593d134ba1f15e9ed0c577fad4f64448d5994

See more details on using hashes here.

Provenance

The following attestation bundles were made for racah_py-0.1.2-cp312-abi3-macosx_10_12_x86_64.whl:

Publisher: wheels.yml on Ryo-wtnb11/racah

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.1.2 This release

6 files

0.1.1

6 files

0.1.0

6 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page