A minimal tournament pairing library for Python.
Project description
NYIG TD
A minimal Python library for tournament pairings.
Features
- Swiss pairing with score-based matching and repeat prevention.
- Seed-based matching (1 vs N, 2 vs N-1).
Installation
pip install nyig-td
Usage
Swiss Pairings
from nyig_td import Participant, create_swiss_pairings
# ... setup players, scores, history ...
pairings = create_swiss_pairings(players, scores, history, round_number=1, bye_history=bye_history)
McMahon Pairings
McMahon pairing is common in Go tournaments. Players start with an initial score based on their rank. The library can automatically extract ranks from participant metadata.
# Participants with rank in metadata
players = [
Participant(id="P1", name="Alice", metadata={"rank": 20}),
Participant(id="P2", name="Bob", metadata={"rank": 19}),
]
t = Tournament(id="T1", name="City Open", participants=players)
# Generate round 1 using metadata ranks automatically
pairings = t.create_round(
type="mcmahon",
top_bar=20,
bottom_bar=10
)
# Inspect match properties
match = pairings[0]
if not match.is_bye:
print(f"Board 1: {match.p1.name} vs {match.p2.name}")
Standings and Metrics
The library provides a powerful metrics engine to calculate standings with custom tie-breaking rules, supporting both Swiss and McMahon formats.
from nyig_td.models import Tournament, MetricsConfig, TieBreaker
# 1. Setup tournament and record matches
t = Tournament(id="T1", name="City Open", participants=players)
# ... add matches and results ...
# 2. Configure standings (optional)
config = MetricsConfig(
tie_breakers=[
TieBreaker.MAIN_SCORE,
TieBreaker.SOS, # Sum of Opponents' Scores
TieBreaker.SODOS, # Sum of Defeated Opponents' Scores
TieBreaker.SOSOS # Sum of Opponents' SOS
],
bye_points=1.0 # Points awarded for a bye
)
# 3. Get standings
standings = t.get_standings(config)
for entry in standings["General"]:
print(f"{entry.rank}. {entry.participant.name} - {entry.main_score} ({entry.record})")
Tournament Divisions
You can automatically group standings by player rank:
from nyig_td.models import DivisionConfig
config = MetricsConfig(
divisions=[
DivisionConfig(name="Open", min_rank=20),
DivisionConfig(name="Intermediate", min_rank=10, max_rank=19),
DivisionConfig(name="Novice", max_rank=9)
]
)
standings_by_div = t.get_standings(config)
# returns {"Open": [...], "Intermediate": [...], "Novice": [...]}
McMahon Standings
To use McMahon Scores (Initial Rank + Points) as the primary metric:
config = MetricsConfig(
use_mcmahon=True,
top_bar=20, # McMahon scores are capped at 20
bottom_bar=5 # McMahon scores are floored at 5
)
standings = t.get_standings(config)
Development
This project uses uv for dependency management.
uv sync
uv run mypy
uv run pytest
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nyig_td-0.1.1.tar.gz.
File metadata
- Download URL: nyig_td-0.1.1.tar.gz
- Upload date:
- Size: 7.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
112e35097bcaeb3fdcccbc42b633d8a9795181ac45e51959b74141c32d508eb5
|
|
| MD5 |
f525dc6364820421b48e56697e280752
|
|
| BLAKE2b-256 |
db9d54319f81171363d16c302dccb84c5a32fa069d3aa576ff4b5a869e293195
|
Provenance
The following attestation bundles were made for nyig_td-0.1.1.tar.gz:
Publisher:
publish.yml on liryan1/nyig-td
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nyig_td-0.1.1.tar.gz -
Subject digest:
112e35097bcaeb3fdcccbc42b633d8a9795181ac45e51959b74141c32d508eb5 - Sigstore transparency entry: 991161521
- Sigstore integration time:
-
Permalink:
liryan1/nyig-td@1b3169ce9a3a0488f289a1b8324a5fe52b6c5447 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/liryan1
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@1b3169ce9a3a0488f289a1b8324a5fe52b6c5447 -
Trigger Event:
push
-
Statement type:
File details
Details for the file nyig_td-0.1.1-py3-none-any.whl.
File metadata
- Download URL: nyig_td-0.1.1-py3-none-any.whl
- Upload date:
- Size: 11.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2a633ce30f2c2692b075062e117df7c219a6f0de7a2e3e3e85284df2925a0c49
|
|
| MD5 |
b336198b98cdc659787f3c7a5d9abbbf
|
|
| BLAKE2b-256 |
57c4c9bfb3b2d3096d8d921bb1eb523a3ba1b16f73c1a6e21a5911c03ed464de
|
Provenance
The following attestation bundles were made for nyig_td-0.1.1-py3-none-any.whl:
Publisher:
publish.yml on liryan1/nyig-td
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nyig_td-0.1.1-py3-none-any.whl -
Subject digest:
2a633ce30f2c2692b075062e117df7c219a6f0de7a2e3e3e85284df2925a0c49 - Sigstore transparency entry: 991161625
- Sigstore integration time:
-
Permalink:
liryan1/nyig-td@1b3169ce9a3a0488f289a1b8324a5fe52b6c5447 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/liryan1
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@1b3169ce9a3a0488f289a1b8324a5fe52b6c5447 -
Trigger Event:
push
-
Statement type: