This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Pymrio is a Python package for Multi-Regional Input-Output (MRIO) analysis focused on environmentally extended MRIO tables. It provides high-level abstractions for global EE MRIO databases like EXIOBASE, WIOD, EORA26, and OECD data.
pytest -n auto- Fast parallel testingpytest --ruff --ruff-format- Full test suite with lintingcoverage run -m pytest --ruff --ruff-format- Test with coveragecoverage report- Show coverage report
ruff format- Format all filesruff check- Lint check (use--fixto auto-fix)ruff check --fix- Lint and auto-fix issues
make -C ./doc clean- Clean documentation buildmake -C ./doc html- Build HTML documentation
poe sync- Sync all dependencies with uvpoe format- Format codepoe check- Run linting checkspoe test- Fast testingpoe fulltest- Full test suite with coveragepoe doc- Build documentationpoe build- Complete build process (format, test, docs)
pymrio/core/
mriosystem.py- MainIOSystemandExtensionclasses that represent MRIO tablesfileio.py- File I/O operations for loading/saving MRIO dataconstants.py- Package constants and configuration
pymrio/tools/
iomath.py- Mathematical operations for MRIO calculations (calc_A, calc_L, etc.)ioparser.py- Parsers for different MRIO database formats (EXIOBASE, WIOD, etc.)iodownloader.py- Automatic download functions for MRIO databasesioutil.py- Utility functions for data manipulation and aggregationioclass.py- Classification data handlingiometadata.py- Metadata management
pymrio/mrio_models/
- Contains test data and concordance files for different MRIO models
test_mrio/- Small test dataset for development and examples
IOSystem- Main class representing a complete MRIO system with matrices (A, L, Z, etc.)Extension- Represents satellite accounts (emissions, land use, etc.)MRIOMetaData- Handles metadata and calculation historyClassificationData- Manages region/sector classifications
The package follows standard MRIO notation:
Z- Inter-industry flow matrixA- Technical coefficient matrixL- Leontief inverse matrixY- Final demand matrixx- Total output vectorF- Environmental extension matrix (direct impacts)S- Environmental multiplier matrix
Tests are located in tests/ directory with mock data in tests/mock_mrios/. The test suite covers:
- Core functionality with small test MRIO
- Parser tests with mock data files
- Mathematical operations
- Integration tests
- Output format validation
Uses modern Python scientific stack:
- pandas >= 2.1 for data handling
- numpy >= 1.20 for numerical operations
- matplotlib for visualization
- requests for downloading data
- xlrd/openpyxl for Excel file support
Project uses:
pyproject.tomlfor configurationuvfor dependency managementrufffor linting and formattingpytestfor testingpoethepoetfor task running- Sphinx for documentation