schur-weyl
Tools from Schur–Weyl duality, built from scratch on top of numpy and the Python standard library — no representation-theory or combinatorics dependencies.
Schur–Weyl duality decomposes $(\mathbb{C}^d)^{\otimes n}$ under the commuting actions of $S_n$ (permuting tensor factors) and $GL_d$ (acting diagonally) into isotypic blocks indexed by partitions $\lambda \vdash n$ with $\ell(\lambda) \le d$:
$$(\mathbb{C}^d)^{\otimes n} \cong \bigoplus_{\lambda} S^\lambda \otimes V_\lambda^d$$
This package implements the combinatorics and linear algebra needed to work with that decomposition directly: partitions and Young tableaux, dimension formulas, symmetric-group characters via Murnaghan–Nakayama, Schur polynomials, Kronecker coefficients, isotypic projectors on tensor space, the Schur–Weyl measure, and Young's orthogonal form for the irreducible representations of $S_n$.
Installation
Requires Python ≥ 3.9.
pip install schur-weyl
The package itself only depends on numpy. For local development (cloning the repo, running the test suite), install it editable with the dev extra instead, which pulls in pytest and ruff:
pip install -e ".[dev]"
Modules
| Module | Contents |
|---|---|
young_diagrams |
Partitions, conjugation, hook lengths, content, dominance order, addable/removable corners |
dimensions |
$f^\lambda$ (Specht module dimension, hook-length formula) and $\dim V_\lambda^d$ (Weyl module dimension, content formula) |
tableaux |
Standard and semistandard Young tableaux, Kostka numbers, reading words |
symmetric_group |
Permutations as 0-indexed one-line tuples: composition, inverse, cycle type, conjugacy class sizes |
character |
Irreducible characters $\chi^\lambda(\mu)$ of $S_n$ via the Murnaghan–Nakayama rule; full character tables |
symmetric_functions |
Schur polynomials (Jacobi–Trudi) and power-sum symmetric functions |
kronecker |
Kronecker coefficients $g(\lambda, \mu, \nu, \dots)$ — the multiplicity of $S^\lambda$ in a tensor product of Specht modules — as a character sum over conjugacy classes |
isotypic |
Isotypic projectors $P_\lambda$ acting on $(\mathbb{C}^d)^{\otimes n}$, built from class sums of the permutation action; apply_isotypic_proj applies $P_\lambda$ along chosen axes of a tensor without materialising the matrix |
sw_measure |
The Schur–Weyl measure $\Pr[\lambda] = f^\lambda, s_\lambda(\mathrm{spec},\rho)$ for i.i.d. copies of a state $\rho$ |
young_orthonormal |
Young's orthogonal form: explicit irrep matrices $\rho^\lambda(\sigma)$ indexed by standard tableaux, and the Jucys–Murphy elements |
Usage
import numpy as np
from schur_weyl import (
partitions, dim_specht, dim_weyl, kostka,
schur_polynomial, kronecker_coefficient,
isotypic_proj, apply_isotypic_proj,
)
from schur_weyl.character import character, character_table
from schur_weyl.sw_measure import schur_weyl_measure
# dimension formulas
dim_specht((2, 1)) # -> 2, the standard rep of S_3
dim_weyl((2, 1), d=3) # -> 8
# characters
character((2, 1), (3,)) # -> -1
# the Schur-Weyl measure for n i.i.d. copies of a state with given spectrum
schur_weyl_measure(spectrum=[0.7, 0.3], k=4)
# -> {(4,): 0.4141, (3, 1): 0.4977, (2, 2): 0.0882, (2, 1, 1): 0.0, (1, 1, 1, 1): 0.0}
# Kronecker coefficients: the multiplicity of S^lam inside a tensor product
# of Specht modules, g(lam, mu, nu, ...), for any number of partitions of n
kronecker_coefficient((3,), (2, 1), (2, 1)) # -> 1
kronecker_coefficient((3,), (2, 1), (1, 1, 1)) # -> 0
# the isotypic projector on (C^d)^{\otimes n}
P = isotypic_proj((2, 1), d=2) # np.ndarray, P @ P == P
# ... or apply it along chosen axes of a tensor, without ever building
# the d^k x d^k matrix. Axes outside `axes` are carried along untouched.
T = np.random.default_rng(0).normal(size=(4, 2, 2, 2, 5))
apply_isotypic_proj(T, (2, 1), axes=(1, 2, 3)) # -> same shape as T
Testing
pytest
Tests live in tests/ and mirror the module layout; most assert the closed-form identities from the roadmap (e.g. $\sum_\lambda (f^\lambda)^2 = n!$, character-table orthogonality, $P_\lambda^2 = P_\lambda$, $tr\rho^\lambda(X_k)$ diagonal with content eigenvalues) rather than fixed expected outputs.
License
MIT — see LICENSE.
Metadata
Release files for schur-weyl 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| schur_weyl-0.2.1.tar.gz | 87.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| schur_weyl-0.2.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 103.6 kB
Release files / schur_weyl-0.2.1.tar.gz
| Download URL | schur_weyl-0.2.1.tar.gz |
|---|---|
| Size | 87.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f14332907078f04e16095ee6325eee54a5905b5a8b9c7d98233b6229d807c449
|
|
BLAKE2b-256 checksum How to use checksums |
17689e6a4fa1614df011ef84dac6fd3ef1585c692892a0c6cfd2a56a278734e1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 7, 2026.
Transparency logRelease files / schur_weyl-0.2.1-py3-none-any.whl
| Download URL | schur_weyl-0.2.1-py3-none-any.whl |
|---|---|
| Size | 16.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cf231352935b8d78174123c07bbd34ec4b24a23eb378b7286a3498a23377905a
|
|
BLAKE2b-256 checksum How to use checksums |
de2b41ab3a6deae15ff87a3ed392e6bbe798d9b39c766b4477cfd3622f7ac42d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 7, 2026.
Transparency log