|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +nflplotpy is a comprehensive Python visualization package for NFL data analysis, providing complete feature parity with R's nflplotR package. It integrates with matplotlib, plotly, seaborn, and pandas to create NFL-themed visualizations including team logos, wordmarks, and player headshots. |
| 8 | + |
| 9 | +## Development Commands |
| 10 | + |
| 11 | +### Environment Setup |
| 12 | +```bash |
| 13 | +# Install in development mode (use .venv if available) |
| 14 | +pip install -e .[dev] |
| 15 | + |
| 16 | +# Install with all optional dependencies |
| 17 | +pip install -e .[all] |
| 18 | +``` |
| 19 | + |
| 20 | +### Testing |
| 21 | +```bash |
| 22 | +# Run all tests |
| 23 | +pytest tests/ |
| 24 | + |
| 25 | +# Run with coverage |
| 26 | +pytest tests/ --cov=nflplotpy |
| 27 | + |
| 28 | +# Run specific test file |
| 29 | +pytest tests/test_core.py -v |
| 30 | +``` |
| 31 | + |
| 32 | +### Code Quality |
| 33 | +```bash |
| 34 | +# Lint with ruff |
| 35 | +ruff check . |
| 36 | + |
| 37 | +# Format with ruff |
| 38 | +ruff format . |
| 39 | + |
| 40 | +# Type checking with mypy |
| 41 | +mypy nflplotpy/ |
| 42 | +``` |
| 43 | + |
| 44 | +### Building |
| 45 | +```bash |
| 46 | +# Build package |
| 47 | +python -m build |
| 48 | + |
| 49 | +# Install built package |
| 50 | +pip install dist/nflplotpy-*.whl |
| 51 | +``` |
| 52 | + |
| 53 | +## Architecture Overview |
| 54 | + |
| 55 | +### Core Components |
| 56 | + |
| 57 | +**nflplotpy/core/**: Foundation modules |
| 58 | +- `colors.py`: NFL team color palettes and management |
| 59 | +- `logos.py`: Asset downloading and caching (NFLAssetManager) |
| 60 | +- `urls.py`: Comprehensive URL management with nfl_data_py integration |
| 61 | +- `plotting.py`: High-level plotting functions |
| 62 | +- `utils.py`: Team validation, factors, and system utilities |
| 63 | +- `assets.py`: Asset management utilities |
| 64 | +- `nfl_data_integration.py`: nfl_data_py integration layer for player ID mapping |
| 65 | + |
| 66 | +**Backend Integrations**: |
| 67 | +- `matplotlib/`: Matplotlib artists, elements, scales, and preview |
| 68 | +- `plotly/`: Plotly layouts and traces |
| 69 | +- `seaborn/`: Seaborn style integration |
| 70 | +- `pandas/`: DataFrame styling with NFL elements |
| 71 | + |
| 72 | +### Key Classes |
| 73 | + |
| 74 | +- **NFLAssetManager**: Handles logo/asset caching and downloads |
| 75 | +- **NFLColorPalette**: Advanced color palette management |
| 76 | +- **AssetURLManager**: Manages URLs for all NFL assets (logos, wordmarks, headshots) |
| 77 | +- **NFLTableStyler**: Pandas DataFrame styling with NFL elements |
| 78 | + |
| 79 | +### Player ID System |
| 80 | + |
| 81 | +The package supports multiple player identification methods: |
| 82 | +- **ESPN IDs**: Numeric ESPN player identifiers |
| 83 | +- **GSIS IDs**: NFL's official player IDs (format: 00-0012345) |
| 84 | +- **Player Names**: Fuzzy matching against player database |
| 85 | +- **Auto-detection**: Automatically determines ID type and converts between formats |
| 86 | + |
| 87 | +Uses `nfl_data_py` for player ID mapping with graceful fallbacks when unavailable. |
| 88 | + |
| 89 | +### Asset Management |
| 90 | + |
| 91 | +- **Logos**: Team logos cached locally, downloaded from nflverse GitHub |
| 92 | +- **Wordmarks**: Team wordmark images from nflverse repository |
| 93 | +- **Headshots**: Player photos from ESPN with ID-based URLs |
| 94 | +- **Caching**: Comprehensive caching system for all assets using appdirs |
| 95 | + |
| 96 | +## Testing Notes |
| 97 | + |
| 98 | +- Full test suite with 108+ tests covering all functionality |
| 99 | +- Tests work with and without nfl_data_py installed (fallback system) |
| 100 | +- Cross-platform compatibility (Windows, macOS, Linux) |
| 101 | +- Mock data available for testing when external dependencies unavailable |
| 102 | + |
| 103 | +## Key Dependencies |
| 104 | + |
| 105 | +**Core**: matplotlib, pandas, numpy, pillow, requests, jinja2, appdirs |
| 106 | +**Optional**: plotly (5.0+), seaborn (0.11+), nfl_data_py (0.3.0+) |
| 107 | + |
| 108 | +## Development Notes |
| 109 | + |
| 110 | +- Python 3.8+ support with type hints |
| 111 | +- Ruff for linting/formatting (line length 88) |
| 112 | +- MyPy for type checking with strict configuration |
| 113 | +- Uses nflverse ecosystem URLs and standards |
| 114 | +- Extensive caching to minimize external requests |
| 115 | +- Graceful degradation when optional dependencies unavailable |
0 commit comments