Skip to main content

schur-weyl

Documentation PyPI

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, full Kostka matrices and their inverses, 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
schur_transform The Schur transform: a real orthogonal $U$ with $U P(\sigma) U^T = \bigoplus_\lambda \mathbb{1} \otimes \rho^\lambda(\sigma)$ in Young's orthogonal form and $U g^{\otimes n} U^T = \bigoplus_\lambda q_\lambda(g) \otimes \mathbb{1}$, also given as one isometry $V_{\lambda,T}$ per standard tableau

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.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for schur-weyl 0.4.0
File Size Uploaded
schur_weyl-0.4.0.tar.gz 95.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for schur-weyl 0.4.0
File Interpreter ABI Platform
schur_weyl-0.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 116.6 kB

Release files / schur_weyl-0.4.0.tar.gz

Download URL schur_weyl-0.4.0.tar.gz
Size 95.1 kB
Tags Source
SHA-256 checksum
How to use checksums
c1a46aca3ce1cc09b24aa87c36426eccff76df3e744121d994644df60bcf215f
BLAKE2b-256 checksum
How to use checksums
8e91d31326ffd09fc22dc9c5a31aae3648b07f6e67d2e76f440b80be765dc923
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 Oct 1, 2026.

Transparency log

Release files / schur_weyl-0.4.0-py3-none-any.whl

Download URL schur_weyl-0.4.0-py3-none-any.whl
Size 21.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4d206ef90adec20e9b3176787ca78e87e4caa82be3cc2b67b9016bcd2ce60ef8
BLAKE2b-256 checksum
How to use checksums
87f2996ac3bbee8a1e8c07c9ee2a02813f62d575e1950cb0cc953b0a737b6f78
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 Oct 1, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.4.0 This release

2 release files

0.3.0

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release 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