tennis-rank
Computes tennis player ranks using pagerank algorithm on match graph
Install
Using pip:
pip install tennisrank
Run tests:
make lint
make test
Example
from tennisrank.utils import load_atp
from tennisrank.model import Player, PlayerRank
from tennisrank.algorithm import TennisRank
matches = load_atp(2021)
ranker = TennisRank(matches)
# Get top 3 on all surfaces
top = 3
for surface in [Surface.ANY, Surface.HARD, Surface.CLAY, Surface.GRASS]:
print(f'Top {top} on {surface.name} surface (unit weight):')
ranks = ranker.get_ranks(surface=surface)
for player_rank in ranks[:top]:
print('-', player_rank)
print(f'{len(ranks)-top} more...')
print()
# Get rank of particular player
ranker.get_rank('Novak Hukohic', surface=Surface.GRASS) # fuzzy matching
Creates the following output:
Top 3 on ANY surface (unit weight):
- PlayerRank(player=Player(id=100644, name='Alexander Zverev'), rank=1, surface=<Surface.ANY: 3>)
- PlayerRank(player=Player(id=104925, name='Novak Djokovic'), rank=2, surface=<Surface.ANY: 3>)
- PlayerRank(player=Player(id=106421, name='Daniil Medvedev'), rank=3, surface=<Surface.ANY: 3>)
389 more...
Top 3 on HARD surface (unit weight):
- PlayerRank(player=Player(id=106421, name='Daniil Medvedev'), rank=1, surface=<Surface.HARD: 0>)
- PlayerRank(player=Player(id=100644, name='Alexander Zverev'), rank=2, surface=<Surface.HARD: 0>)
- PlayerRank(player=Player(id=104925, name='Novak Djokovic'), rank=3, surface=<Surface.HARD: 0>)
316 more...
Top 3 on CLAY surface (unit weight):
- PlayerRank(player=Player(id=104745, name='Rafael Nadal'), rank=1, surface=<Surface.CLAY: 2>)
- PlayerRank(player=Player(id=104925, name='Novak Djokovic'), rank=2, surface=<Surface.CLAY: 2>)
- PlayerRank(player=Player(id=126774, name='Stefanos Tsitsipas'), rank=3, surface=<Surface.CLAY: 2>)
221 more...
Top 3 on GRASS surface (unit weight):
- PlayerRank(player=Player(id=104925, name='Novak Djokovic'), rank=1, surface=<Surface.GRASS: 1>)
- PlayerRank(player=Player(id=200000, name='Felix Auger Aliassime'), rank=2, surface=<Surface.GRASS: 1>)
- PlayerRank(player=Player(id=126610, name='Matteo Berrettini'), rank=3, surface=<Surface.GRASS: 1>)
164 more...
(PlayerRank(player=Player(id=104925, name='Novak Djokovic'), rank=1, surface=<Surface.GRASS: 1>),
0.7407407407407407)
Publish new version
For developers
Via Github Actions
- Update version number in pyproject.toml
- Merge to main (via PR, direct push to main or other way)
- Create new release on Github
Direct to PyPI
Build and upload:
python -m build
twine upload dist/*
Metadata
Release files for tennisrank 0.1.8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| tennisrank-0.1.8.tar.gz | 9.6 kB | Without provenance | Details for tennisrank-0.1.8.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| tennisrank-0.1.8-py3-none-any.whl | Python 3 | none | any | Details for tennisrank-0.1.8-py3-none-any.whl |
Total release size: 19.3 kB
Release files / tennisrank-0.1.8.tar.gz
| Download URL | tennisrank-0.1.8.tar.gz |
|---|---|
| Size | 9.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
118a089ab303383959c1f0aaf6e7277c2a922c7e2986aef5140de3046941e217
|
|
BLAKE2b-256 checksum How to use checksums |
a91e1b18f4ac2c1f4a682822021e7f8117ce5f1d6fb7b3b8c97313505df9750e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.9.18
|
Release files / tennisrank-0.1.8-py3-none-any.whl
| Download URL | tennisrank-0.1.8-py3-none-any.whl |
|---|---|
| Size | 9.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c78e18322a4f8837ee9979eb4e88a2cf09cb45b7cd28b0e00525ae48d16846fd
|
|
BLAKE2b-256 checksum How to use checksums |
74bd8392df3103edf7574dcfb622bd9ee6576bf20a704f3588bcc4040858b212
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.9.18
|
Security for tennisrank 0.1.8
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.