Skip to content

Commit eb7fbdf

Browse files
build: harden project with CI matrix, ruff, coverage and vectorized modules
- Add lint+format job and Python 3.9-3.13 test matrix to CI - Consolidate pytest/ruff config in pyproject (remove pytest.ini) - Vectorize Prog_Ratio computation (drop per-row lambdas) and fix path resolution - Add integration tests for load_data, _prog_ratio edge cases and plot module - Add .editorconfig, CONTRIBUTING.md and professional README with TOC
1 parent a07f61e commit eb7fbdf

15 files changed

Lines changed: 1014 additions & 292 deletions

File tree

.editorconfig

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# EditorConfig is awesome: https://EditorConfig.org
2+
3+
root = true
4+
5+
[*]
6+
charset = utf-8
7+
end_of_line = lf
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
indent_style = space
11+
indent_size = 4
12+
13+
[*.md]
14+
trim_trailing_whitespace = false
15+
16+
[*.yml]
17+
indent_size = 2
18+
19+
[*.yaml]
20+
indent_size = 2
21+
22+
[*.json]
23+
indent_size = 2

.github/workflows/ci.yml

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,52 @@ on:
77
branches: [ main ]
88

99
jobs:
10-
test:
10+
lint:
1111
runs-on: ubuntu-latest
1212
steps:
1313
- uses: actions/checkout@v4
1414

1515
- name: Set up Python
1616
uses: actions/setup-python@v5
1717
with:
18-
python-version: '3.10'
18+
python-version: "3.12"
1919

2020
- name: Install dependencies
2121
run: |
2222
python -m pip install --upgrade pip
23-
pip install -e .
24-
pip install -r requirements.txt
23+
pip install -e ".[dev]"
2524
26-
- name: Run tests
25+
- name: Ruff lint
26+
run: ruff check .
27+
28+
- name: Ruff format check
29+
run: ruff format --check .
30+
31+
test:
32+
runs-on: ubuntu-latest
33+
strategy:
34+
fail-fast: false
35+
matrix:
36+
python-version: ["3.9", "3.11", "3.12", "3.13"]
37+
steps:
38+
- uses: actions/checkout@v4
39+
40+
- name: Set up Python ${{ matrix.python-version }}
41+
uses: actions/setup-python@v5
42+
with:
43+
python-version: ${{ matrix.python-version }}
44+
45+
- name: Install dependencies
2746
run: |
28-
pytest -q
47+
python -m pip install --upgrade pip
48+
pip install -e ".[dev]"
49+
50+
- name: Run tests
51+
run: pytest
52+
53+
- name: Upload coverage report
54+
uses: actions/upload-artifact@v4
55+
with:
56+
name: coverage-${{ matrix.python-version }}
57+
path: coverage.xml
58+
if: always()

.gitignore

Lines changed: 68 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,72 @@
1-
.venv/
1+
# Python
22
__pycache__/
3-
*.pyc
4-
.DS_Store
3+
*.py[cod]
4+
*$py.class
5+
*.so
6+
.Python
7+
build/
8+
develop-eggs/
9+
dist/
10+
downloads/
11+
eggs/
12+
.eggs/
13+
lib/
14+
lib64/
15+
parts/
16+
sdist/
17+
var/
18+
wheels/
19+
share/python-wheels/
20+
*.egg-info/
21+
.installed.cfg
22+
*.egg
23+
MANIFEST
24+
25+
# Virtual environments
26+
.venv/
27+
venv/
28+
env/
29+
ENV/
30+
env.bak/
31+
venv.bak/
32+
33+
# Testing / coverage
34+
.pytest_cache/
35+
.ruff_cache/
36+
.mypy_cache/
37+
htmlcov/
38+
.tox/
39+
.nox/
40+
.coverage
41+
.coverage.*
42+
coverage.xml
43+
*.cover
44+
45+
# Jupyter / IPython
46+
.ipynb_checkpoints
47+
profile_default/
48+
ipython_config.py
49+
50+
# Environments / secrets
551
.env
6-
*.xlsx
52+
.env.*
53+
!.env.example
54+
*.pem
55+
*.key
756

8-
# Python__pycache__/
9-
*.pyc
10-
# Streamlit.streamlit/
57+
# Streamlit
58+
.streamlit/
59+
60+
# OS generated files
61+
.DS_Store
62+
.DS_Store?
63+
._*
64+
.Spotlight-V100
65+
.Trashes
66+
ehthumbs.db
67+
Thumbs.db
68+
desktop.ini
1169

70+
# Editors
71+
.vscode/
72+
.idea/

CONTRIBUTING.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Contributing / Contribución
2+
3+
¡Gracias por tu interés en mejorar este proyecto! Sigue estas pautas para mantener la calidad y consistencia del código base.
4+
5+
## Flujo de trabajo
6+
7+
1. Haz un fork del repositorio y crea una rama descriptiva:
8+
```bash
9+
git checkout -b feat/nombre-de-la-mejora
10+
```
11+
2. Realiza cambios pequeños y enfocados.
12+
3. Escribe o actualiza pruebas para cubrir tu cambio.
13+
4. Verifica localmente lint y tests:
14+
```bash
15+
pip install -e ".[dev]"
16+
ruff check .
17+
ruff format --check .
18+
pytest
19+
```
20+
5. Envía un pull request contra `main`.
21+
22+
## Convenciones
23+
24+
- **Commits:** [Conventional Commits](https://www.conventionalcommits.org/) (`feat:`, `fix:`, `refactor:`, `test:`, `docs:`, `ci:`, `chore:`).
25+
- **Estilo de código:** `ruff check` y `ruff format` (100 columnas).
26+
- **Idioma:** los identificadores, docstrings y mensajes de commit en inglés; los comentarios explicativos pueden ser en español.
27+
28+
## Reglas de código
29+
30+
- Sigue **DRY/KISS/SOLID**: reutiliza los módulos existentes en `src/united_passing/` antes de duplicar lógica.
31+
- No introduzcas secretos ni credenciales: usa variables de entorno y `.env.example`.
32+
- Toda función pública debe tener docstring y anotaciones de tipos donde aporte claridad.
33+
34+
## Reportar problemas
35+
36+
Usa [GitHub Issues](https://github.com/alvarosalinaso/united-passing-efficiency-24-25/issues) con un título claro y una descripción que incluya el paso para reproducirlo.

README.md

Lines changed: 64 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,23 @@
11
# Passing Efficiency — Manchester United 2024-25
22

33
[![CI](https://github.com/alvarosalinaso/united-passing-efficiency-24-25/actions/workflows/ci.yml/badge.svg)](https://github.com/alvarosalinaso/united-passing-efficiency-24-25/actions/workflows/ci.yml)
4-
[![Python](https://img.shields.io/badge/Python-3.8%2B-blue)](https://python.org)
4+
[![Python](https://img.shields.io/badge/Python-3.9%2B-blue)](https://python.org)
55
[![Streamlit](https://img.shields.io/badge/Streamlit-FF4B4B?logo=streamlit)](https://streamlit.io)
66
[![License](https://img.shields.io/badge/license-MIT-green)](LICENSE)
77

88
Dashboard táctico que analiza la eficiencia de pases del mediocampo del Manchester United (temporada 2024-2025). Incluye ranking de jugadores, mapas de calor por zona del campo, redes de pases basadas en grafos y evolución temporal de métricas clave.
99

10+
## Tabla de contenidos
11+
12+
- [Dashboard en Vivo](#dashboard-en-vivo)
13+
- [Stack](#stack)
14+
- [Arquitectura](#arquitectura)
15+
- [Instalación](#instalación)
16+
- [Inicio Rápido](#inicio-rápido)
17+
- [Testing](#testing)
18+
- [Contribución](#contribución)
19+
- [Licencia](#licencia)
20+
1021
## Dashboard en Vivo
1122

1223
👉 **[united-passing-efficiency-24-25.streamlit.app](https://united-passing-efficiency-24-25.streamlit.app)**
@@ -15,14 +26,32 @@ Dashboard táctico que analiza la eficiencia de pases del mediocampo del Manches
1526

1627
| Capa | Tecnología |
1728
|------|-----------|
18-
| **Lenguaje** | Python 3.8+ |
29+
| **Lenguaje** | Python 3.9+ |
1930
| **Data** | Pandas, NumPy |
2031
| **Visualización** | Streamlit, Plotly, Matplotlib |
2132
| **Análisis** | SciPy (métricas de centralidad en grafos de pases) |
22-
| **Testing** | Pytest |
23-
| **CI/CD** | GitHub Actions |
33+
| **Testing** | Pytest, Pytest-cov |
34+
| **Lint & Format** | Ruff |
35+
| **CI/CD** | GitHub Actions (matrix 3.9–3.13) |
2436
| **Licencia** | MIT |
2537

38+
## Arquitectura
39+
40+
```
41+
┌─────────────┐ ┌──────────────┐ ┌──────────────┐
42+
│ data.py │──▶│ analysis.py │──▶│ plot.py │
43+
│ (carga/ │ │ (métricas) │ │ (visualiza) │
44+
│ limpieza) │ └──────────────┘ └──────────────┘
45+
└─────────────┘ │
46+
│ ▼
47+
└───────────▶ app.py (Streamlit) ──▶ Dashboard
48+
```
49+
50+
- **data.py** — carga, resolución de rutas y limpieza vectorizada (sin `apply` en bucles).
51+
- **analysis.py** — métricas tácticas y top-N por ratio progresivo.
52+
- **plot.py** — visualizaciones Matplotlib/Seaborn reutilizables.
53+
- **app.py** — capa de presentación (Streamlit) que orquesta los módulos.
54+
2655
## Estructura
2756

2857
```
@@ -31,26 +60,49 @@ united-passing-efficiency-24-25/
3160
│ ├── data.py # Carga y validación
3261
│ ├── analysis.py # Métricas tácticas
3362
│ └── plot.py # Visualizaciones
34-
├── tests/ # Tests unitarios
35-
├── .github/workflows/ # CI pipeline
63+
├── tests/ # Tests unitarios e integración
64+
├── .github/workflows/ # CI pipeline (lint + matrix de tests + coverage)
3665
├── app.py # Dashboard Streamlit
3766
├── passing.csv # Datos de pases
3867
├── reporte_mediocampo.csv # Reporte filtrado mediocampo
39-
├── pyproject.toml # Configuración
40-
└── requirements.txt # Dependencias
68+
├── pyproject.toml # Configuración (build, ruff, pytest, coverage)
69+
└── requirements.txt # Dependencias en runtime
4170
```
4271

43-
## Inicio Rápido
72+
## Instalación
4473

4574
```bash
75+
git clone https://github.com/alvarosalinaso/united-passing-efficiency-24-25.git
76+
cd united-passing-efficiency-24-25
77+
python -m venv .venv
78+
# Windows: .venv\Scripts\activate | Linux/macOS: source .venv/bin/activate
4679
pip install -r requirements.txt
80+
```
81+
82+
Para desarrollo (incluye linters y tests):
83+
84+
```bash
85+
pip install -e ".[dev]"
86+
```
87+
88+
## Inicio Rápido
89+
90+
```bash
4791
streamlit run app.py
4892
```
4993

94+
## Testing
95+
5096
```bash
51-
pytest # Tests
97+
pytest # Tests + cobertura
98+
ruff check . # Lint
99+
ruff format --check . # Verificación de formato
52100
```
53101

54-
## Contacto
102+
## Contribución
103+
104+
Revisa [CONTRIBUTING.md](CONTRIBUTING.md) para convenciones de commits, estilo de código y flujo de PRs.
105+
106+
## Licencia
55107

56-
**Álvaro Salinas Ortiz**[LinkedIn](https://linkedin.com/in/alvaro-salinas-ortiz) · alvarosalinasortiz@gmail.com
108+
Distribuido bajo la licencia [MIT](LICENSE). Copyright © 2026 Álvaro Salinas.

0 commit comments

Comments
 (0)