Registry / data / ldpc
library2.4.1pypypi✓ verified 80d ago

A Python library for constructing, encoding, and decoding Low Density Parity Check (LDPC) codes. Current version 2.4.1, active development with periodic releases. Supports a variety of constructions (e.g., random, protograph, QCLDPC) and decoders (belief propagation, min-sum).

pip install ldpc
INSTALL
IMPORT
SIG · LDPC
L
ldpc
datapythonv2.4.1
Install
15.4s avg
Import
Disk
398MB
Pass rate
4/ 10
Env Coverage4 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v2.4.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
glibc
py 3.10
✕ build_error
✓ 15.3s
py 3.11
✕ build_error
✓ 14.7s
py 3.12
✕ build_error
✓ 15.6s
py 3.13
✕ build_error
✓ 15.9s
py 3.9
✕ build_error
✕ build_error
398MB installed
● package 398MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

BeliefFindDecoder
from ldpc import BeliefFindDecoder
from ldpc import LdpcCode
BpDecoder
from ldpc import BpDecoder
from ldpc import RandomLdpcCode
UnionFindDecoder
from ldpc import UnionFindDecoder
from ldpc import ProtographLdpcCode

Basic example: create a random LDPC code, encode, add noise, and decode.

import numpy as np from ldpc import RandomLdpcCode, LdpcEncoder, LdpcDecoder # Create a random LDPC code with rate 0.5, block length 100 code = RandomLdpcCode(block_len=100, rate=0.5) # Encode: generate random message msg = np.random.randint(0, 2, code.k) codeword = code.encode(msg) # Introduce noise (BSC) noise = np.random.binomial(1, 0.1, codeword.shape) received = (codeword + noise) % 2 # Decode decoder = code.decoder() decoded = decoder.decode(received, max_iter=50) print('Decoded correctly:', np.array_equal(decoded, codeword))
Debug
Known issues
breakingIn version 2.0+, the internal package structure was refactored. Custom parity-check matrices (H) must be passed as numpy arrays or scipy sparse matrices, not as lists.
fix
Ensure H is a 2D numpy array. Use np.array(H_list) if you have a list of lists.
affects: >=2.0.0
gotchaThe decoder's decode() method expects a 1D array of received symbols (0/1 for BSC, or soft bits for AWGN). For soft decoding, set decoder_type='bp' and provide log-likelihood ratios.
fix
For BSC: received = (codeword + noise) % 2. For AWGN: received = -2*noisey_llr + 1 (or similar).
affects: all
deprecatedThe function `ldpc.decode` (top-level) is deprecated; use `LdpcDecoder.decode` instead.
fix
Replace `ldpc.decode(...)` with `decoder.decode(...)` where decoder = code.decoder().
affects: >=2.0.0
Upgrade
Version history
2.4.1latest on PyPI · released Dec 8, 2025
Audit
Dependencies
numpyrequiredCore dependency for array operations.
scipyrequiredUsed for sparse matrix operations and linear algebra.
numbaoptionalUsed for JIT compilation of decoding loops (optional but recommended for performance).
Agent activity
4 hits · last 30 days
node
4
Resources
ldpc — pip install ldpc · libregistry