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

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.3.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.3.0
File Size Uploaded
schur_weyl-0.3.0.tar.gz 90.6 kB Details

Built distribution (wheel)

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

Total release size: 109.0 kB

Release files / schur_weyl-0.3.0.tar.gz

Download URL schur_weyl-0.3.0.tar.gz
Size 90.6 kB
Tags Source
SHA-256 checksum
How to use checksums
9192efa1c5b7e937f338e62e9cd894a5b11ec093c37f76832a44bd1f0410d9dd
BLAKE2b-256 checksum
How to use checksums
a5dcba5ba324c7ede768c998b56a128042b2ce821df3c244b17e4c4bac964479
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 30, 2026.

Transparency log

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

Download URL schur_weyl-0.3.0-py3-none-any.whl
Size 18.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
18f2ddf9d6f3d6604231b9621702defae684b99d09f32e6cd8238f2297c31af4
BLAKE2b-256 checksum
How to use checksums
896b024824f4e853b1a4f17382566273596f59c32c6d801a0766b874b8241648
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 30, 2026.

Transparency log

Release history Release notifications | RSS feed

0.4.0

2 release files

This release

0.3.0 This release

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